From 3a1352a68657a7506f37eab1f91057912063aa69 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Tue, 5 Jul 2011 10:48:57 -0700 Subject: [PATCH] Cleanup internal naming convention. --- libmemcached/auto.cc | 8 ++++---- libmemcached/behavior.cc | 4 ++-- libmemcached/callback.cc | 4 ++-- libmemcached/common.h | 2 +- libmemcached/delete.cc | 10 +++++----- libmemcached/get.cc | 14 +++++++------- libmemcached/hash.cc | 8 ++++---- libmemcached/memcached.cc | 14 +++++++------- libmemcached/memcached.h | 4 ++-- libmemcached/namespace.cc | 10 +++++----- libmemcached/response.cc | 10 +++++----- libmemcached/storage.cc | 12 ++++++------ tests/mem_functions.cc | 4 ++-- 13 files changed, 52 insertions(+), 52 deletions(-) diff --git a/libmemcached/auto.cc b/libmemcached/auto.cc index f1494ac3..f06d9ca0 100644 --- a/libmemcached/auto.cc +++ b/libmemcached/auto.cc @@ -60,7 +60,7 @@ static memcached_return_t text_incr_decr(memcached_st *ptr, int send_length; send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "%s %.*s%.*s %" PRIu64 "%s\r\n", verb, - memcached_print_array(ptr->prefix_key), + memcached_print_array(ptr->_namespace), (int)key_length, key, offset, no_reply ? " noreply" : ""); if (send_length >= MEMCACHED_DEFAULT_COMMAND_SIZE || send_length < 0) @@ -133,10 +133,10 @@ static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd, request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= cmd; - request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->prefix_key))); + request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->_namespace))); request.message.header.request.extlen= 20; request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; - request.message.header.request.bodylen= htonl((uint32_t)(key_length + memcached_array_size(ptr->prefix_key) +request.message.header.request.extlen)); + request.message.header.request.bodylen= htonl((uint32_t)(key_length + memcached_array_size(ptr->_namespace) +request.message.header.request.extlen)); request.message.body.delta= memcached_htonll(offset); request.message.body.initial= memcached_htonll(initial); request.message.body.expiration= htonl((uint32_t) expiration); @@ -144,7 +144,7 @@ static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd, struct libmemcached_io_vector_st vector[]= { { sizeof(request.bytes), request.bytes }, - { memcached_array_size(ptr->prefix_key), memcached_array_string(ptr->prefix_key) }, + { memcached_array_size(ptr->_namespace), memcached_array_string(ptr->_namespace) }, { key_length, key } }; diff --git a/libmemcached/behavior.cc b/libmemcached/behavior.cc index 330be0b8..0c182ec2 100644 --- a/libmemcached/behavior.cc +++ b/libmemcached/behavior.cc @@ -212,7 +212,7 @@ memcached_return_t memcached_behavior_set(memcached_st *ptr, memcached_literal_param("MEMCACHED_BEHAVIOR_USER_DATA deprecated.")); case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: - ptr->flags.hash_with_prefix_key= bool(data); + ptr->flags.hash_with_namespace= bool(data); break; case MEMCACHED_BEHAVIOR_NOREPLY: @@ -415,7 +415,7 @@ uint64_t memcached_behavior_get(memcached_st *ptr, return 0; case MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY: - return ptr->flags.hash_with_prefix_key; + return ptr->flags.hash_with_namespace; case MEMCACHED_BEHAVIOR_NOREPLY: return ptr->flags.no_reply; diff --git a/libmemcached/callback.cc b/libmemcached/callback.cc index 4eab7e49..47397863 100644 --- a/libmemcached/callback.cc +++ b/libmemcached/callback.cc @@ -97,10 +97,10 @@ void *memcached_callback_get(memcached_st *ptr, { case MEMCACHED_CALLBACK_PREFIX_KEY: { - if (ptr->prefix_key) + if (ptr->_namespace) { *error= MEMCACHED_SUCCESS; - return (void *)memcached_array_string(ptr->prefix_key); + return (void *)memcached_array_string(ptr->_namespace); } else { diff --git a/libmemcached/common.h b/libmemcached/common.h index ac300def..46230ce3 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -100,7 +100,7 @@ memcached_return_t memcached_server_execute(memcached_st *ptr, #include #include #include -#include +#include /* string value */ struct memcached_continuum_item_st diff --git a/libmemcached/delete.cc b/libmemcached/delete.cc index e4738517..7ef05b07 100644 --- a/libmemcached/delete.cc +++ b/libmemcached/delete.cc @@ -134,7 +134,7 @@ memcached_return_t memcached_delete_by_key(memcached_st *ptr, } send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "delete %.*s%.*s %u%s\r\n", - memcached_print_array(ptr->prefix_key), + memcached_print_array(ptr->_namespace), (int) key_length, key, (uint32_t)expiration, no_reply ? " noreply" :"" ); @@ -144,7 +144,7 @@ memcached_return_t memcached_delete_by_key(memcached_st *ptr, { send_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "delete %.*s%.*s%s\r\n", - memcached_print_array(ptr->prefix_key), + memcached_print_array(ptr->_namespace), (int)key_length, key, no_reply ? " noreply" :""); } @@ -208,9 +208,9 @@ static inline memcached_return_t binary_delete(memcached_st *ptr, { request.message.header.request.opcode= PROTOCOL_BINARY_CMD_DELETE; } - request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->prefix_key))); + request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; - request.message.header.request.bodylen= htonl((uint32_t)(key_length + memcached_array_size(ptr->prefix_key))); + request.message.header.request.bodylen= htonl((uint32_t)(key_length + memcached_array_size(ptr->_namespace))); if (ptr->flags.use_udp && ! flush) { @@ -225,7 +225,7 @@ static inline memcached_return_t binary_delete(memcached_st *ptr, struct libmemcached_io_vector_st vector[]= { { sizeof(request.bytes), request.bytes}, - { memcached_array_size(ptr->prefix_key), memcached_array_string(ptr->prefix_key) }, + { memcached_array_size(ptr->_namespace), memcached_array_string(ptr->_namespace) }, { key_length, key }, }; diff --git a/libmemcached/get.cc b/libmemcached/get.cc index bcc2dd8c..dcb9f001 100644 --- a/libmemcached/get.cc +++ b/libmemcached/get.cc @@ -300,7 +300,7 @@ static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, struct libmemcached_io_vector_st vector[]= { { get_command_length, get_command }, - { memcached_array_size(ptr->prefix_key), memcached_array_string(ptr->prefix_key) }, + { memcached_array_size(ptr->_namespace), memcached_array_string(ptr->_namespace) }, { key_length[x], keys[x] }, { 1, " " } }; @@ -493,14 +493,14 @@ static memcached_return_t simple_binary_mget(memcached_st *ptr, return vk; } - request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->prefix_key))); + request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; - request.message.header.request.bodylen= htonl((uint32_t)( key_length[x] + memcached_array_size(ptr->prefix_key))); + request.message.header.request.bodylen= htonl((uint32_t)( key_length[x] + memcached_array_size(ptr->_namespace))); struct libmemcached_io_vector_st vector[]= { { sizeof(request.bytes), request.bytes }, - { memcached_array_size(ptr->prefix_key), memcached_array_string(ptr->prefix_key) }, + { memcached_array_size(ptr->_namespace), memcached_array_string(ptr->_namespace) }, { key_length[x], keys[x] } }; @@ -612,9 +612,9 @@ static memcached_return_t replication_binary_mget(memcached_st *ptr, protocol_binary_request_getk request= {}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK; - request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->prefix_key))); + request.message.header.request.keylen= htons((uint16_t)(key_length[x] + memcached_array_size(ptr->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; - request.message.header.request.bodylen= htonl((uint32_t)(key_length[x] + memcached_array_size(ptr->prefix_key))); + request.message.header.request.bodylen= htonl((uint32_t)(key_length[x] + memcached_array_size(ptr->_namespace))); /* * We need to disable buffering to actually know that the request was @@ -629,7 +629,7 @@ static memcached_return_t replication_binary_mget(memcached_st *ptr, struct libmemcached_io_vector_st vector[]= { { sizeof(request.bytes), request.bytes }, - { memcached_array_size(ptr->prefix_key), memcached_array_string(ptr->prefix_key) }, + { memcached_array_size(ptr->_namespace), memcached_array_string(ptr->_namespace) }, { key_length[x], keys[x] } }; diff --git a/libmemcached/hash.cc b/libmemcached/hash.cc index e239320d..ae07dfd0 100644 --- a/libmemcached/hash.cc +++ b/libmemcached/hash.cc @@ -107,16 +107,16 @@ static inline uint32_t _generate_hash_wrapper(const memcached_st *ptr, const cha if (memcached_server_count(ptr) == 1) return 0; - if (ptr->flags.hash_with_prefix_key) + if (ptr->flags.hash_with_namespace) { - size_t temp_length= memcached_array_size(ptr->prefix_key) + key_length; + size_t temp_length= memcached_array_size(ptr->_namespace) + key_length; char temp[MEMCACHED_MAX_KEY]; if (temp_length > MEMCACHED_MAX_KEY -1) return 0; - strncpy(temp, memcached_array_string(ptr->prefix_key), memcached_array_size(ptr->prefix_key)); - strncpy(temp + memcached_array_size(ptr->prefix_key), key, key_length); + strncpy(temp, memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace)); + strncpy(temp + memcached_array_size(ptr->_namespace), key, key_length); return generate_hash(ptr, temp, temp_length); } diff --git a/libmemcached/memcached.cc b/libmemcached/memcached.cc index f35e7cc9..359a4403 100644 --- a/libmemcached/memcached.cc +++ b/libmemcached/memcached.cc @@ -51,7 +51,7 @@ static const memcached_st global_copy= { .auto_eject_hosts= false, .binary_protocol= false, .buffer_requests= false, - .hash_with_prefix_key= false, + .hash_with_namespace= false, .no_block= false, .no_reply= false, .randomize_replica_read= false, @@ -74,7 +74,7 @@ static inline bool _memcached_init(memcached_st *self) self->flags.auto_eject_hosts= false; self->flags.binary_protocol= false; self->flags.buffer_requests= false; - self->flags.hash_with_prefix_key= false; + self->flags.hash_with_namespace= false; self->flags.no_block= false; self->flags.no_reply= false; self->flags.randomize_replica_read= false; @@ -135,7 +135,7 @@ static inline bool _memcached_init(memcached_st *self) self->sasl.is_allocated= false; self->error_messages= NULL; - self->prefix_key= NULL; + self->_namespace= NULL; self->configure.initial_pool_size= 1; self->configure.max_pool_size= 1; self->configure.version= -1; @@ -160,8 +160,8 @@ static void _free(memcached_st *ptr, bool release_st) libmemcached_free(ptr, ptr->ketama.continuum); - memcached_array_free(ptr->prefix_key); - ptr->prefix_key= NULL; + memcached_array_free(ptr->_namespace); + ptr->_namespace= NULL; memcached_error_free(*ptr); @@ -371,8 +371,8 @@ memcached_st *memcached_clone(memcached_st *clone, const memcached_st *source) } - new_clone->prefix_key= memcached_array_clone(new_clone, source->prefix_key); - new_clone->configure.filename= memcached_array_clone(new_clone, source->prefix_key); + new_clone->_namespace= memcached_array_clone(new_clone, source->_namespace); + new_clone->configure.filename= memcached_array_clone(new_clone, source->_namespace); #ifdef LIBMEMCACHED_WITH_SASL_SUPPORT if (source->sasl.callbacks) diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 099a4b30..440898e1 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -98,7 +98,7 @@ struct memcached_st { bool auto_eject_hosts:1; bool binary_protocol:1; bool buffer_requests:1; - bool hash_with_prefix_key:1; + bool hash_with_namespace:1; bool no_block:1; // Don't block bool no_reply:1; bool randomize_replica_read:1; @@ -151,7 +151,7 @@ struct memcached_st { memcached_callback_st *callbacks; struct memcached_sasl_st sasl; struct memcached_error_t *error_messages; - struct memcached_array_st *prefix_key; + struct memcached_array_st *_namespace; struct { uint32_t initial_pool_size; uint32_t max_pool_size; diff --git a/libmemcached/namespace.cc b/libmemcached/namespace.cc index d9961e29..372af2a9 100644 --- a/libmemcached/namespace.cc +++ b/libmemcached/namespace.cc @@ -67,18 +67,18 @@ memcached_return_t memcached_set_namespace(memcached_st *self, const char *key, return memcached_set_error(*self, MEMCACHED_KEY_TOO_BIG, MEMCACHED_AT); } - memcached_array_free(self->prefix_key); - self->prefix_key= memcached_strcpy(self, key, key_length); + memcached_array_free(self->_namespace); + self->_namespace= memcached_strcpy(self, key, key_length); - if (not self->prefix_key) + if (not self->_namespace) { return memcached_set_error(*self, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT); } } else { - memcached_array_free(self->prefix_key); - self->prefix_key= NULL; + memcached_array_free(self->_namespace); + self->_namespace= NULL; } return MEMCACHED_SUCCESS; diff --git a/libmemcached/response.cc b/libmemcached/response.cc index ce649bcb..1548b4ed 100644 --- a/libmemcached/response.cc +++ b/libmemcached/response.cc @@ -142,7 +142,7 @@ static memcached_return_t textual_value_fetch(memcached_server_write_instance_st key= result->item_key; result->key_length= 0; - for (prefix_length= memcached_array_size(ptr->root->prefix_key); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++) + for (prefix_length= memcached_array_size(ptr->root->_namespace); !(iscntrl(*string_ptr) || isspace(*string_ptr)) ; string_ptr++) { if (prefix_length == 0) { @@ -418,15 +418,15 @@ static memcached_return_t binary_read_one_response(memcached_server_write_instan // Only bother with doing this if key_length > 0 if (result->key_length) { - if (memcached_array_size(ptr->root->prefix_key) and memcached_array_size(ptr->root->prefix_key) >= result->key_length) + if (memcached_array_size(ptr->root->_namespace) and memcached_array_size(ptr->root->_namespace) >= result->key_length) { return memcached_set_error(*ptr, MEMCACHED_UNKNOWN_READ_FAILURE, MEMCACHED_AT); } - if (memcached_array_size(ptr->root->prefix_key)) + if (memcached_array_size(ptr->root->_namespace)) { - result->key_length-= memcached_array_size(ptr->root->prefix_key); - memmove(result->item_key, result->item_key +memcached_array_size(ptr->root->prefix_key), result->key_length); + result->key_length-= memcached_array_size(ptr->root->_namespace); + memmove(result->item_key, result->item_key +memcached_array_size(ptr->root->_namespace), result->key_length); } } diff --git a/libmemcached/storage.cc b/libmemcached/storage.cc index fece7f9f..ffe7faae 100644 --- a/libmemcached/storage.cc +++ b/libmemcached/storage.cc @@ -111,7 +111,7 @@ static inline memcached_return_t memcached_send(memcached_st *ptr, check_length= snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, "%s %.*s%.*s %u %llu %lu %llu%s\r\n", storage_op_string(verb), - memcached_print_array(ptr->prefix_key), + memcached_print_array(ptr->_namespace), (int)key_length, key, flags, (unsigned long long)expiration, (unsigned long)value_length, (unsigned long long)cas, @@ -134,10 +134,10 @@ static inline memcached_return_t memcached_send(memcached_st *ptr, memcpy(buffer_ptr, command, strlen(command)); /* Copy in the key prefix, switch to the buffer_ptr */ - buffer_ptr= (char *)memcpy((char *)(buffer_ptr + strlen(command)), (char *)memcached_array_string(ptr->prefix_key), memcached_array_size(ptr->prefix_key)); + buffer_ptr= (char *)memcpy((char *)(buffer_ptr + strlen(command)), (char *)memcached_array_string(ptr->_namespace), memcached_array_size(ptr->_namespace)); /* Copy in the key, adjust point if a key prefix was used. */ - buffer_ptr= (char *)memcpy(buffer_ptr + memcached_array_size(ptr->prefix_key), + buffer_ptr= (char *)memcpy(buffer_ptr + memcached_array_size(ptr->_namespace), key, key_length); buffer_ptr+= key_length; buffer_ptr[0]= ' '; @@ -481,7 +481,7 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= get_com_code(verb, noreply); - request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->prefix_key))); + request.message.header.request.keylen= htons((uint16_t)(key_length + memcached_array_size(ptr->_namespace))); request.message.header.request.datatype= PROTOCOL_BINARY_RAW_BYTES; if (verb == APPEND_OP || verb == PREPEND_OP) send_length -= 8; /* append & prepend does not contain extras! */ @@ -492,7 +492,7 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, request.message.body.expiration= htonl((uint32_t)expiration); } - request.message.header.request.bodylen= htonl((uint32_t) (key_length + memcached_array_size(ptr->prefix_key) + value_length + + request.message.header.request.bodylen= htonl((uint32_t) (key_length + memcached_array_size(ptr->_namespace) + value_length + request.message.header.request.extlen)); if (cas) @@ -517,7 +517,7 @@ static memcached_return_t memcached_send_binary(memcached_st *ptr, struct libmemcached_io_vector_st vector[]= { { send_length, request.bytes }, - { memcached_array_size(ptr->prefix_key), memcached_array_string(ptr->prefix_key) }, + { memcached_array_size(ptr->_namespace), memcached_array_string(ptr->_namespace) }, { key_length, key }, { value_length, value } }; diff --git a/tests/mem_functions.cc b/tests/mem_functions.cc index 180f1e7e..f70dbba4 100644 --- a/tests/mem_functions.cc +++ b/tests/mem_functions.cc @@ -330,7 +330,7 @@ static test_return_t clone_test(memcached_st *memc) test_true(memc_clone->flags.verify_key == memc->flags.verify_key); test_true(memc_clone->ketama.weighted == memc->ketama.weighted); test_true(memc_clone->flags.binary_protocol == memc->flags.binary_protocol); - test_true(memc_clone->flags.hash_with_prefix_key == memc->flags.hash_with_prefix_key); + test_true(memc_clone->flags.hash_with_namespace == memc->flags.hash_with_namespace); test_true(memc_clone->flags.no_reply == memc->flags.no_reply); test_true(memc_clone->flags.use_udp == memc->flags.use_udp); test_true(memc_clone->flags.auto_eject_hosts == memc->flags.auto_eject_hosts); @@ -1725,7 +1725,7 @@ static test_return_t mget_test(memcached_st *memc) { test_true(return_value); test_compare(MEMCACHED_SUCCESS, rc); - if (not memc->prefix_key) + if (not memc->_namespace) { test_compare(return_key_length, return_value_length); test_memcmp(return_value, return_key, return_value_length); -- 2.30.2