From: Brian Aker Date: Tue, 29 Jan 2013 19:08:15 +0000 (-0500) Subject: Cleanup for F18 build notices. X-Git-Tag: 1.0.16~2^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=2e68927d2a57a3ac8fe420a3014686a795521548;p=m6w6%2Flibmemcached Cleanup for F18 build notices. --- diff --git a/libmemcached/callback.cc b/libmemcached/callback.cc index bb001feb..a43eef93 100644 --- a/libmemcached/callback.cc +++ b/libmemcached/callback.cc @@ -31,7 +31,7 @@ memcached_return_t memcached_callback_set(memcached_st *shell, { case MEMCACHED_CALLBACK_PREFIX_KEY: { - return memcached_set_namespace(ptr, (char*)data, data ? strlen((char*)data) : 0); + return memcached_set_namespace(*ptr, (char*)data, data ? strlen((char*)data) : 0); } case MEMCACHED_CALLBACK_USER_DATA: diff --git a/libmemcached/common.h b/libmemcached/common.h index 4ab26806..fac6d775 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -158,11 +158,11 @@ org::libmemcached::Instance* memcached_instance_fetch(memcached_st *ptr, uint32_ #ifdef __cplusplus # include "libmemcached/response.h" +# include "libmemcached/namespace.h" +#else +# include "libmemcached/virtual_bucket.h" #endif -#include "libmemcached/namespace.h" -#include "libmemcached/virtual_bucket.h" - #ifdef __cplusplus # include "libmemcached/backtrace.hpp" # include "libmemcached/assert.hpp" diff --git a/libmemcached/csl/parser.yy b/libmemcached/csl/parser.yy index 09356949..6d4ccd55 100644 --- a/libmemcached/csl/parser.yy +++ b/libmemcached/csl/parser.yy @@ -291,7 +291,7 @@ behaviors: parser_abort(context, "--NAMESPACE can only be called once"); } - if ((context->rc= memcached_set_namespace(context->memc, $2.c_str, $2.size)) != MEMCACHED_SUCCESS) + if ((context->rc= memcached_set_namespace(*context->memc, $2.c_str, $2.size)) != MEMCACHED_SUCCESS) { parser_abort(context, memcached_last_error_message(context->memc)); } diff --git a/libmemcached/encoding_key.cc b/libmemcached/encoding_key.cc index 5888d439..1e17d507 100644 --- a/libmemcached/encoding_key.cc +++ b/libmemcached/encoding_key.cc @@ -2,7 +2,7 @@ * * Libmemcached library * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -38,19 +38,19 @@ #include #include -static void _set_encoding_key(Memcached& self, const char *key, size_t key_length) +static void _set_encoding_key(Memcached& memc, const char *key, size_t key_length) { - hashkit_key(&self.hashkit, key, key_length); + hashkit_key(&memc.hashkit, key, key_length); } memcached_return_t memcached_set_encoding_key(memcached_st* shell, const char *key, size_t key_length) { - Memcached* self= memcached2Memcached(shell); - if (self == NULL) + Memcached* memc= memcached2Memcached(shell); + if (memc) { - return MEMCACHED_INVALID_ARGUMENTS; + _set_encoding_key(*memc, key, key_length); + return MEMCACHED_SUCCESS; } - _set_encoding_key(*self, key, key_length); - return MEMCACHED_SUCCESS; + return MEMCACHED_INVALID_ARGUMENTS; } diff --git a/libmemcached/encoding_key.h b/libmemcached/encoding_key.h index 87b2f4ea..a2c47b08 100644 --- a/libmemcached/encoding_key.h +++ b/libmemcached/encoding_key.h @@ -41,7 +41,7 @@ extern "C" { #endif - memcached_string_t memcached_encoding_key(memcached_st&); + memcached_string_t memcached_encoding_key(Memcached&); #ifdef __cplusplus } diff --git a/libmemcached/namespace.cc b/libmemcached/namespace.cc index 6a9ec243..664ebc4e 100644 --- a/libmemcached/namespace.cc +++ b/libmemcached/namespace.cc @@ -35,62 +35,60 @@ * */ -#include -#include +#include "libmemcached/common.h" +#include "libmemcached/assert.hpp" -memcached_return_t memcached_set_namespace(memcached_st *self, const char *key, size_t key_length) +memcached_return_t memcached_set_namespace(Memcached& memc, const char *key, size_t key_length) { - assert_msg(self, "A NULL memcached_st was used"); - if (key and key_length == 0) { WATCHPOINT_ASSERT(key_length); - return memcached_set_error(*self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid namespace, namespace string had value but length was 0")); + return memcached_set_error(memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid namespace, namespace string had value but length was 0")); } else if (key_length and key == NULL) { WATCHPOINT_ASSERT(key); - return memcached_set_error(*self, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid namespace, namespace string length was > 1 but namespace string was null ")); + return memcached_set_error(memc, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_AT, memcached_literal_param("Invalid namespace, namespace string length was > 1 but namespace string was null ")); } else if (key and key_length) { - bool orig= self->flags.verify_key; - self->flags.verify_key= true; - if (memcached_failed(memcached_key_test(*self, (const char **)&key, &key_length, 1))) + bool orig= memc.flags.verify_key; + memc.flags.verify_key= true; + if (memcached_failed(memcached_key_test(memc, (const char **)&key, &key_length, 1))) { - self->flags.verify_key= orig; - return memcached_last_error(self); + memc.flags.verify_key= orig; + return memcached_last_error(&memc); } - self->flags.verify_key= orig; + memc.flags.verify_key= orig; if ((key_length > MEMCACHED_PREFIX_KEY_MAX_SIZE -1)) { - return memcached_set_error(*self, MEMCACHED_KEY_TOO_BIG, MEMCACHED_AT); + return memcached_set_error(memc, MEMCACHED_KEY_TOO_BIG, MEMCACHED_AT); } - memcached_array_free(self->_namespace); - self->_namespace= memcached_strcpy(self, key, key_length); + memcached_array_free(memc._namespace); + memc._namespace= memcached_strcpy(&memc, key, key_length); - if (not self->_namespace) + if (memc._namespace == NULL) { - return memcached_set_error(*self, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); + return memcached_set_error(memc, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } } else { - memcached_array_free(self->_namespace); - self->_namespace= NULL; + memcached_array_free(memc._namespace); + memc._namespace= NULL; } return MEMCACHED_SUCCESS; } -const char * memcached_get_namespace(memcached_st *self) +const char * memcached_get_namespace(Memcached& memc) { - if (self->_namespace == NULL) + if (memc._namespace == NULL) { return NULL; } - return memcached_array_string(self->_namespace); + return memcached_array_string(memc._namespace); } diff --git a/libmemcached/namespace.h b/libmemcached/namespace.h index 04622571..0c98ce4c 100644 --- a/libmemcached/namespace.h +++ b/libmemcached/namespace.h @@ -38,15 +38,9 @@ #pragma once #ifdef __cplusplus -extern "C" { -#endif -LIBMEMCACHED_LOCAL - memcached_return_t memcached_set_namespace(memcached_st *self, const char *str, size_t length); +memcached_return_t memcached_set_namespace(Memcached&, const char *str, size_t length); -LIBMEMCACHED_LOCAL - const char * memcached_get_namespace(memcached_st *self); +const char * memcached_get_namespace(Memcached&); -#ifdef __cplusplus -} -#endif +#endif // __cplusplus diff --git a/libmemcached/virtual_bucket.c b/libmemcached/virtual_bucket.c index 8af3a72f..92c5dc45 100644 --- a/libmemcached/virtual_bucket.c +++ b/libmemcached/virtual_bucket.c @@ -55,7 +55,7 @@ memcached_return_t memcached_virtual_bucket_create(memcached_st *self, const uint32_t buckets, const uint32_t replicas) { - if (! self || ! host_map || ! buckets) + if (self == NULL || host_map == NULL || buckets == 0U) { return MEMCACHED_INVALID_ARGUMENTS; } @@ -93,37 +93,31 @@ memcached_return_t memcached_virtual_bucket_create(memcached_st *self, void memcached_virtual_bucket_free(memcached_st *self) { - if (self == NULL) + if (self) { - return; - } - - if (self->virtual_bucket == NULL) - { - return; + if (self->virtual_bucket) + { + free(self->virtual_bucket); + self->virtual_bucket= NULL; + } } - - free(self->virtual_bucket); - self->virtual_bucket= NULL; } uint32_t memcached_virtual_bucket_get(const memcached_st *self, uint32_t digest) { - if (self == NULL) + if (self) { - return 0; - } - - if (self->virtual_bucket == NULL) - { - return 0; - } + if (self->virtual_bucket) + { + if (self->virtual_bucket) + { + uint32_t result= (uint32_t) (digest & (self->virtual_bucket->size -1)); + return self->virtual_bucket->buckets[result].master; + } - if (self->virtual_bucket) - { - uint32_t result= (uint32_t) (digest & (self->virtual_bucket->size -1)); - return self->virtual_bucket->buckets[result].master; + return (uint32_t) (digest & (self->number_of_hosts -1)); + } } - return (uint32_t) (digest & (self->number_of_hosts -1)); + return 0; } diff --git a/libmemcached/virtual_bucket.h b/libmemcached/virtual_bucket.h index e1c38536..9a63c38f 100644 --- a/libmemcached/virtual_bucket.h +++ b/libmemcached/virtual_bucket.h @@ -2,7 +2,7 @@ * * Libmemcached library * - * Copyright (C) 2011 Data Differential, http://datadifferential.com/ + * Copyright (C) 2011-2013 Data Differential, http://datadifferential.com/ * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -41,17 +41,14 @@ extern "C" { #endif -LIBMEMCACHED_LOCAL memcached_return_t memcached_virtual_bucket_create(memcached_st *self, const uint32_t *host_map, const uint32_t *forward_map, const uint32_t buckets, const uint32_t replicas); -LIBMEMCACHED_LOCAL uint32_t memcached_virtual_bucket_get(const memcached_st *self, uint32_t digest); -LIBMEMCACHED_LOCAL void memcached_virtual_bucket_free(memcached_st *self); #ifdef __cplusplus