From: Brian Aker Date: Wed, 16 Dec 2009 18:53:44 +0000 (-0800) Subject: Style cleanup X-Git-Tag: 0.37~76 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b4de8d3fd063b9017797dd9809ab3acb8a537606;p=m6w6%2Flibmemcached Style cleanup --- diff --git a/clients/execute.c b/clients/execute.c index 30fb5f18..3944d449 100644 --- a/clients/execute.c +++ b/clients/execute.c @@ -9,7 +9,7 @@ unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int number_of) { - memcached_return rc; + memcached_return_t rc; unsigned int x; unsigned int pairs_sent; @@ -34,7 +34,7 @@ unsigned int execute_set(memcached_st *memc, pairs_st *pairs, unsigned int numbe */ unsigned int execute_get(memcached_st *memc, pairs_st *pairs, unsigned int number_of) { - memcached_return rc; + memcached_return_t rc; unsigned int x; unsigned int retrieved; @@ -66,7 +66,7 @@ unsigned int execute_get(memcached_st *memc, pairs_st *pairs, unsigned int numbe /** * Callback function to count the number of results */ -static memcached_return callback_counter(memcached_st *ptr, +static memcached_return_t callback_counter(memcached_st *ptr, memcached_result_st *result, void *context) { @@ -92,8 +92,8 @@ unsigned int execute_mget(memcached_st *memc, unsigned int number_of) { unsigned int retrieved= 0; - memcached_execute_function callbacks[1]= { [0]= &callback_counter }; - memcached_return rc; + memcached_execute_fn callbacks[1]= { [0]= &callback_counter }; + memcached_return_t rc; rc= memcached_mget_execute(memc, keys, key_length, (size_t)number_of, callbacks, &retrieved, 1); diff --git a/clients/memcat.c b/clients/memcat.c index 944afe72..9ea6f33b 100644 --- a/clients/memcat.c +++ b/clients/memcat.c @@ -27,7 +27,7 @@ int main(int argc, char *argv[]) char *string; size_t string_length; uint32_t flags; - memcached_return rc; + memcached_return_t rc; memcached_server_st *servers; options_parse(argc, argv); diff --git a/clients/memcp.c b/clients/memcp.c index dcc142da..bdab6b09 100644 --- a/clients/memcp.c +++ b/clients/memcp.c @@ -34,7 +34,7 @@ static time_t opt_expires= 0; int main(int argc, char *argv[]) { memcached_st *memc; - memcached_return rc; + memcached_return_t rc; memcached_server_st *servers; options_parse(argc, argv); diff --git a/clients/memdump.c b/clients/memdump.c index 1a21ab64..4705bcad 100644 --- a/clients/memdump.c +++ b/clients/memdump.c @@ -29,9 +29,9 @@ static char *opt_servers= NULL; static char *opt_hash= NULL; /* Print the keys and counter how many were found */ -static memcached_return key_printer(memcached_st *ptr __attribute__((unused)), - const char *key, size_t key_length, - void *context __attribute__((unused))) +static memcached_return_t key_printer(memcached_st *ptr __attribute__((unused)), + const char *key, size_t key_length, + void *context __attribute__((unused))) { printf("%.*s\n", (uint32_t)key_length, key); @@ -41,9 +41,9 @@ static memcached_return key_printer(memcached_st *ptr __attribute__((unused)), int main(int argc, char *argv[]) { memcached_st *memc; - memcached_return rc; + memcached_return_t rc; memcached_server_st *servers; - memcached_dump_func callbacks[1]; + memcached_dump_fn callbacks[1]; callbacks[0]= &key_printer; diff --git a/clients/memflush.c b/clients/memflush.c index 12034adb..bc12ae8d 100644 --- a/clients/memflush.c +++ b/clients/memflush.c @@ -21,7 +21,7 @@ void options_parse(int argc, char *argv[]); int main(int argc, char *argv[]) { memcached_st *memc; - memcached_return rc; + memcached_return_t rc; memcached_server_st *servers; options_parse(argc, argv); diff --git a/clients/memrm.c b/clients/memrm.c index 203146ef..1a616482 100644 --- a/clients/memrm.c +++ b/clients/memrm.c @@ -22,7 +22,7 @@ void options_parse(int argc, char *argv[]); int main(int argc, char *argv[]) { memcached_st *memc; - memcached_return rc; + memcached_return_t rc; memcached_server_st *servers; options_parse(argc, argv); diff --git a/clients/memstat.c b/clients/memstat.c index 847e7f0d..8e007753 100644 --- a/clients/memstat.c +++ b/clients/memstat.c @@ -47,7 +47,7 @@ static struct option long_options[]= int main(int argc, char *argv[]) { - memcached_return rc; + memcached_return_t rc; memcached_st *memc; memcached_stat_st *memc_stat; memcached_server_st *servers; @@ -102,7 +102,7 @@ int main(int argc, char *argv[]) static void run_analyzer(memcached_st *memc, memcached_stat_st *memc_stat, memcached_server_st *server_list) { - memcached_return rc; + memcached_return_t rc; if (analyze_mode == NULL) { @@ -219,7 +219,7 @@ static void print_server_listing(memcached_st *memc, memcached_stat_st *memc_sta memcached_server_st *server_list) { unsigned int x; - memcached_return rc; + memcached_return_t rc; printf("Listing %u Server\n\n", memcached_server_count(memc)); for (x= 0; x < memcached_server_count(memc); x++) diff --git a/clients/utilities.c b/clients/utilities.c index e7d8df94..53a366b2 100644 --- a/clients/utilities.c +++ b/clients/utilities.c @@ -81,7 +81,7 @@ void help_command(const char *command_name, const char *description, void process_hash_option(memcached_st *memc, char *opt_hash) { uint64_t set; - memcached_return rc; + memcached_return_t rc; if (opt_hash == NULL) return; diff --git a/docs/libmemcached.pod b/docs/libmemcached.pod index e1a95a73..4c85b5b4 100644 --- a/docs/libmemcached.pod +++ b/docs/libmemcached.pod @@ -32,7 +32,7 @@ allocated and then initialized by memcached_create(). Functions have been written in order to encapsulate the C. It is not recommended that you operate directly against the structure. -Nearly all functions return a C value. +Nearly all functions return a C value. This value can be translated to a printable string with memcached_strerror(3). Partitioning based on keys is supported in the library. Using the key partioning diff --git a/docs/libmemcached_examples.pod b/docs/libmemcached_examples.pod index 510c9206..31328b9a 100644 --- a/docs/libmemcached_examples.pod +++ b/docs/libmemcached_examples.pod @@ -11,7 +11,7 @@ the library. =head2 Creating and Freeing structure memcached_st *memc; - memcached_return rc; + memcached_return_t rc; memc= memcached_create(NULL); ...do stuff... @@ -74,7 +74,7 @@ It is best practice to always look at the return value of any operation. =head2 Fetching multiple values - memcached_return rc; + memcached_return_t rc; char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; unsigned int x; diff --git a/docs/memcached_analyze.pod b/docs/memcached_analyze.pod index 346a1bdb..c4894726 100644 --- a/docs/memcached_analyze.pod +++ b/docs/memcached_analyze.pod @@ -10,9 +10,10 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_analysis_st *memcached_analyze(memcached_st *ptr, - memcached_stat_st *stat, - memcached_return *error); + memcached_analysis_st * + memcached_analyze (memcached_st *ptr, + memcached_stat_st *stat, + memcached_return_t *error); =head1 DESCRIPTION @@ -31,7 +32,7 @@ you do not have to write an application to use this method. A pointer to the allocated C structure on success and a NULL pointer on failure. You may inspect the error detail by checking the -C value. +C value. Any method returning a C expects you to free the memory allocated for it. diff --git a/docs/memcached_auto.pod b/docs/memcached_auto.pod index 482ac77c..305451b6 100644 --- a/docs/memcached_auto.pod +++ b/docs/memcached_auto.pod @@ -12,19 +12,19 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return + memcached_return_t memcached_increment (memcached_st *ptr, const char *key, size_t key_length, unsigned int offset, uint64_t *value); - memcached_return + memcached_return_t memcached_decrement (memcached_st *ptr, const char *key, size_t key_length, unsigned int offset, uint64_t *value); - memcached_return + memcached_return_t memcached_increment_with_initial (memcached_st *ptr, const char *key, size_t key_length, @@ -33,7 +33,7 @@ C Client Library for memcached (libmemcached, -lmemcached) time_t expiration, uint64_t *value); - memcached_return + memcached_return_t memcached_decrement_with_initial (memcached_st *ptr, const char *key, size_t key_length, @@ -42,21 +42,21 @@ C Client Library for memcached (libmemcached, -lmemcached) time_t expiration, uint64_t *value); - memcached_return + memcached_return_t memcached_increment_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, unsigned int offset, uint64_t *value); - memcached_return + memcached_return_t memcached_decrement_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, unsigned int offset, uint64_t *value); - memcached_return + memcached_return_t memcached_increment_with_initial_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, @@ -67,7 +67,7 @@ C Client Library for memcached (libmemcached, -lmemcached) time_t expiration, uint64_t *value); - memcached_return + memcached_return_t memcached_decrement_with_initial_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, @@ -117,7 +117,7 @@ above. =head1 RETURN -A value of type C is returned. +A value of type C is returned. On success that value will be C. Use memcached_strerror() to translate this value to a printable string. diff --git a/docs/memcached_behavior.pod b/docs/memcached_behavior.pod index 0288feb0..da851000 100644 --- a/docs/memcached_behavior.pod +++ b/docs/memcached_behavior.pod @@ -14,7 +14,7 @@ C Client Library for memcached (libmemcached, -lmemcached) memcached_behavior_get (memcached_st *ptr, memcached_behavior flag); - memcached_return + memcached_return_t memcached_behavior_set (memcached_st *ptr, memcached_behavior flag, uint64_t data); diff --git a/docs/memcached_callback.pod b/docs/memcached_callback.pod index 6eba4f32..5d7fed2d 100644 --- a/docs/memcached_callback.pod +++ b/docs/memcached_callback.pod @@ -10,15 +10,15 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return + memcached_return_t memcached_callback_set (memcached_st *ptr, - memcached_callback flag, + memcached_callback_t flag, void *data); void * memcached_callback_get (memcached_st *ptr, - memcached_callback flag, - memcached_return *error); + memcached_callback_t flag, + memcached_return_t *error); =head1 DESCRIPTION @@ -84,7 +84,7 @@ MEMCACHED_SUCCESS or MEMCACHED_BUFFERED. Returning MEMCACHED_BUFFERED will cause the object to be buffered and not sent immediatly (if this is the default behavior based on your connection setup this will happen automatically). The prototype for this is: -memcached_return (*memcached_trigger_key)(memcached_st *ptr, char *key, size_t key_length, memcached_result_st *result); +memcached_return_t (*memcached_trigger_key)(memcached_st *ptr, char *key, size_t key_length, memcached_result_st *result); =item MEMCACHED_CALLBACK_DELETE_TRIGGER @@ -92,7 +92,7 @@ This function implements a trigger upon successful deletion of a key. The memcac in order to make use of it. The prototype for this is: -typedef memcached_return (*memcached_trigger_delete_key)(memcached_st *ptr, char *key, size_t key_length); +typedef memcached_return_t (*memcached_trigger_delete_key)(memcached_st *ptr, char *key, size_t key_length); =back @@ -100,7 +100,7 @@ typedef memcached_return (*memcached_trigger_delete_key)(memcached_st *ptr, char =head1 RETURN memcached_callback_get() return the function or structure that was provided. -Upon error, nothing is set, null is returned, and the memcached_return +Upon error, nothing is set, null is returned, and the memcached_return_t argument is set to MEMCACHED_FAILURE. memcached_callback_set() returns MEMCACHED_SUCCESS upon successful setting, diff --git a/docs/memcached_create.pod b/docs/memcached_create.pod index 6150f002..8c6a1a22 100644 --- a/docs/memcached_create.pod +++ b/docs/memcached_create.pod @@ -14,7 +14,7 @@ C Client Library for memcached (libmemcached, -lmemcached) void memcached_free (memcached_st *ptr); - memcached_st *memcached_clone(memcached_st *clone, memcached_st *source); + memcached_st *memcached_clone (memcached_st *destination, memcached_st *source); =head1 DESCRIPTION @@ -26,23 +26,24 @@ a NULL. If a NULL passed in then a structure is allocated for you. memcached_clone() is similar to memcached_create(3) but it copies the defaults and list of servers from the source C. If you pass a null as the argument for the source to clone, it is the same as a call to memcached_create(). -If the clone argument is NULL a C will be allocated for you. -If you pass a pointer to a memory area for the clone pointer, make sure you -memset it to 0 (unless you got the clone from a factory method in libmemcached). +If the destination argument is NULL a C will be allocated for you. To clean up memory associated with a C structure you should pass it to memcached_free() when you are finished using it. memcached_free() is the only way to make sure all memory is deallocated when you finish using the structure. +You may wish to avoid using memcached_create(3) or memcached_clone(3) with a +stack based allocation. The most common issues related to ABI safety involve +heap allocated structures. + =head1 RETURN memcached_create() returns a pointer to the memcached_st that was created (or initialized). On an allocation failure, it returns NULL. memcached_clone() returns a pointer to the memcached_st that was created -(or initialized). On an allocation failure, it returns NULL. If you pass in -a preallocated structure it must be cleared first (aka memset()). +(or initialized). On an allocation failure, it returns NULL. =head1 HOME diff --git a/docs/memcached_delete.pod b/docs/memcached_delete.pod index 4a4c76e5..07ec865c 100644 --- a/docs/memcached_delete.pod +++ b/docs/memcached_delete.pod @@ -10,12 +10,12 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return + memcached_return_t memcached_delete (memcached_st *ptr, const char *key, size_t key_length, time_t expiration); - memcached_return + memcached_return_t memcached_delete_by_key (memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -34,7 +34,7 @@ find the given value. =head1 RETURN -A value of type C is returned +A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. diff --git a/docs/memcached_dump.pod b/docs/memcached_dump.pod index a80a60d6..cf596335 100644 --- a/docs/memcached_dump.pod +++ b/docs/memcached_dump.pod @@ -10,13 +10,13 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return + memcached_return_t memcached_dump (memcached_st *ptr, - memcached_dump_func *function, + memcached_dump_fn *function, void *context, uint32_t number_of_callbacks); - typedef memcached_return (*memcached_dump_func)(memcached_st *ptr, + typedef memcached_return_t (*memcached_dump_fn)(memcached_st *ptr, const char *key, size_t key_length, void *context); @@ -32,7 +32,7 @@ Currently the binar protocol is not supported. =head1 RETURN -A value of type C is returned +A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. diff --git a/docs/memcached_flush.pod b/docs/memcached_flush.pod index 0249fdab..9a853ee4 100644 --- a/docs/memcached_flush.pod +++ b/docs/memcached_flush.pod @@ -10,7 +10,7 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return + memcached_return_t memcached_flush (memcached_st *ptr, time_t expiration); @@ -25,7 +25,7 @@ added. =head1 RETURN -A value of type C is returned +A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. diff --git a/docs/memcached_flush_buffers.pod b/docs/memcached_flush_buffers.pod index a655e70b..7dd98032 100644 --- a/docs/memcached_flush_buffers.pod +++ b/docs/memcached_flush_buffers.pod @@ -10,18 +10,18 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return + memcached_return_t memcached_flush_buffers (memcached_st *ptr); =head1 DESCRIPTION memcached_flush_buffers() is used in conjunction with MEMCACHED_BEHAVIOR_BUFFER_REQUESTS (see memcached_behavior(3)) to flush -all buffers by sending the buffered commands to the server for processing.. +all buffers by sending the buffered commands to the server for processing. =head1 RETURN -A value of type C is returned +A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. diff --git a/docs/memcached_generate_hash_value.pod b/docs/memcached_generate_hash_value.pod index dd45ab3e..477fbf5b 100644 --- a/docs/memcached_generate_hash_value.pod +++ b/docs/memcached_generate_hash_value.pod @@ -13,7 +13,7 @@ C Client Library for memcached (libmemcached, -lmemcached) uint32_t memcached_generate_hash_value (const char *key, size_t key_length, - memcached_hash hash_algorithm); + memcached_hash_t hash_algorithm); uint32_t memcached_generate_hash (memcached_st *ptr, @@ -34,6 +34,9 @@ memcached_generate_hash() takes a memcached_st struture and produces the hash value that would have been generated based on the defaults of the memcached_st structure. +As of version 0.36 all hash methods have been placed into the library +libhashkit(3) which is linked with libmemcached(3). + =head1 RETURN A 32-bit integer which is the result of hashing the given key. @@ -51,7 +54,7 @@ Brian Aker, Ebrian@tangent.orgE =head1 SEE ALSO -memcached(1) libmemcached(3) memcached_behavior_set(3) +memcached(1) libmemcached(3) memcached_behavior_set(3) libhashkit(3) =cut diff --git a/docs/memcached_get.pod b/docs/memcached_get.pod index db2c9b5a..9423635e 100644 --- a/docs/memcached_get.pod +++ b/docs/memcached_get.pod @@ -12,68 +12,70 @@ C Client Library for memcached (libmemcached, -lmemcached) #include memcached_result_st * - memcached_fetch_result(memcached_st *ptr, - memcached_result_st *result, - memcached_return *error); - - char *memcached_get (memcached_st *ptr, - const char *key, size_t key_length, - size_t *value_length, - uint32_t *flags, - memcached_return *error); - - memcached_return - memcached_mget (memcached_st *ptr, - const char * const *keys, - const size_t *key_length, + memcached_fetch_result (memcached_st *ptr, + memcached_result_st *result, + memcached_return_t *error); + + char * + memcached_get (memcached_st *ptr, + const char *key, size_t key_length, + size_t *value_length, + uint32_t *flags, + memcached_return_t *error); + + memcached_return_t + memcached_mget (memcached_st *ptr, + const char * const *keys, + const size_t *key_length, size_t number_of_keys); char * - memcached_get_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - size_t *value_length, - uint32_t *flags, - memcached_return *error); - - memcached_return - memcached_mget_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys); - - char *memcached_fetch (memcached_st *ptr, - char *key, size_t *key_length, - size_t *value_length, - uint32_t *flags, - memcached_return *error); - - memcached_return - memcached_fetch_execute(memcached_st *ptr, - memcached_return (*callback[])(memcached_st *ptr, memcached_result_st *result, void *context), - void *context, - unsigned int number_of_callbacks); - - - memcached_return - memcached_mget_execute(memcached_st *ptr, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - memcached_execute_function *callback, - void *context, - unsigned int number_of_callbacks); - - memcached_return - memcached_mget_execute_by_key(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - memcached_execute_function *callback, - void *context, - unsigned int number_of_callbacks); + memcached_get_by_key (memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + size_t *value_length, + uint32_t *flags, + memcached_return_t *error); + + memcached_return_t + memcached_mget_by_key (memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys); + + char * + memcached_fetch (memcached_st *ptr, + char *key, size_t *key_length, + size_t *value_length, + uint32_t *flags, + memcached_return_t *error); + + memcached_return_t + memcached_fetch_execute (memcached_st *ptr, + memcached_execute_fn *callback, + void *context, + uint32_t number_of_callbacks); + + + memcached_return_t + memcached_mget_execute (memcached_st *ptr, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_fn *callback, + void *context, + uint32_t number_of_callbacks); + + memcached_return_t + memcached_mget_execute_by_key (memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_fn *callback, + void *context, + uint32_t number_of_callbacks); =head1 DESCRIPTION @@ -83,9 +85,9 @@ must pass in a key and its length to fetch the object. You must supply three pointer variables which will give you the state of the returned object. A uint32_t pointer to contain whatever flags you stored with the value, a size_t pointer which will be filled with size of of the object, and a -memcached_return pointer to hold any error. The object will be returned +memcached_return_t pointer to hold any error. The object will be returned upon success and NULL will be returned on failure. Any object returned by -memcached_get() must be released by the caller application. +memcached_get() must be released by the caller application. memcached_mget() is used to select multiple keys at once. For multiple key operations it is always faster to use this function. This function always @@ -97,28 +99,28 @@ return NULL (aka no more values). If you need to quit in the middle of a memcached_get() call, execute a memcached_quit(). After you do this, you can issue new queries against the server. -memcached_fetch() is used to fetch an individual value from the server. +memcached_fetch() is used to fetch an individual value from the server. memcached_mget() must always be called before using this method. You must pass in a key and its length to fetch the object. You must supply three pointer variables which will give you the state of the returned object. A uint32_t pointer to contain whatever flags you stored with the value, a size_t pointer which will be filled with size of of the object, and a -memcached_return pointer to hold any error. The object will be returned +memcached_return_t pointer to hold any error. The object will be returned upon success and NULL will be returned on failure. MEMCACHD_END is returned -by the *error value when all objects that have been found are returned. +by the *error value when all objects that have been found are returned. The final value upon MEMCACHED_END is null. Values returned by memcached_fetch() musted be free'ed by the caller. -memcached_fetch_result() is used to return a memcached_result_st(3) structure +memcached_fetch_result() is used to return a memcached_result_st(3) structure from a memcached server. The result object is forward compatible with changes -to the server. For more information please refer to the memcached_result_st(3) +to the server. For more information please refer to the memcached_result_st(3) help. This function will dynamically allocate a result structure for you if you do not pass one to the function. memcached_fetch_execute() is a callback function for result sets. Instead of returning the results to you for processing, it passes each of the result sets to the list of functions you provide. It passes to the function -a memcached_st that can be cloned for use in the called function (it can not +a memcached_st that can be cloned for use in the called function (it can not be used directly). It also passes a result set which does not need to be freed. Finally it passes a "context". This is just a pointer to a memory reference you supply the calling function. Currently only one value is being passed @@ -141,9 +143,9 @@ a master key that is used for determining which server an object was stored if key partitioning was used for storage. All of the above functions are not supported when the C -has been set. Executing any of these functions with this behavior on will result in +has been set. Executing any of these functions with this behavior on will result in C being returned or, for those functions which do not return -a C, the error function parameter will be set to +a C, the error function parameter will be set to C. =head1 RETURN diff --git a/docs/memcached_memory_allocators.pod b/docs/memcached_memory_allocators.pod index 72fb1259..e0cd8466 100644 --- a/docs/memcached_memory_allocators.pod +++ b/docs/memcached_memory_allocators.pod @@ -10,25 +10,33 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return - memcached_set_memory_allocators(memcached_st *ptr, - memcached_malloc_function mem_malloc, - memcached_free_function mem_free, - memcached_realloc_function mem_realloc, - memcached_calloc_function mem_calloc); - - void memcached_get_memory_allocators(memcached_st *ptr, - memcached_malloc_function *mem_malloc, - memcached_free_function *mem_free, - memcached_realloc_function *mem_realloc, - memcached_calloc_function *mem_calloc); - - void *(*memcached_malloc_function)(memcached_st *ptr, const size_t size); - void *(*memcached_realloc_function)(memcached_st *ptr, void *mem, - const size_t size); - void (*memcached_free_function)(memcached_st *ptr, void *mem); - void *(*memcached_calloc_function)(memcached_st *ptr, size_t nelem, - const size_t elsize); + memcached_return_t + memcached_set_memory_allocators (memcached_st *ptr, + memcached_malloc_fn mem_malloc, + memcached_free_fn mem_free, + memcached_realloc_fn mem_realloc, + memcached_calloc_fn mem_calloc); + + void + memcached_get_memory_allocators (memcached_st *ptr, + memcached_malloc_fn *mem_malloc, + memcached_free_fn *mem_free, + memcached_realloc_fn *mem_realloc, + memcached_calloc_fn *mem_calloc); + + void * + (*memcached_malloc_fn) (memcached_st *ptr, const size_t size); + + void * + (*memcached_realloc_fn) (memcached_st *ptr, void *mem, + const size_t size); + + void + (*memcached_free_fn) (memcached_st *ptr, void *mem); + + void * + (*memcached_calloc_fn) (memcached_st *ptr, size_t nelem, + const size_t elsize); =head1 DESCRIPTION @@ -53,7 +61,7 @@ structure. =head1 RETURN -memcached_set_memory_allocators() return MEMCACHED_SUCCESS upon success, +memcached_set_memory_allocators() return MEMCACHED_SUCCESS upon success, and MEMCACHED_FAILURE if you don't pass a complete set of function pointers. =head1 HOME diff --git a/docs/memcached_pool.pod b/docs/memcached_pool.pod index ac85d3b9..d5f90bbf 100644 --- a/docs/memcached_pool.pod +++ b/docs/memcached_pool.pod @@ -10,20 +10,29 @@ C Client Library for memcached (libmemcachedutil, -lmemcachedutil) #include - memcached_pool_st *memcached_pool_create(memcached_st* mmc, int initial, int max); - memcached_st* memcached_pool_destroy(memcached_pool_st* pool); + memcached_pool_st * + memcached_pool_create(memcached_st* mmc, int initial, int max); - memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, memcached_return *rc); - memcached_return memcached_pool_push(memcached_pool_st* pool, memcached_st *mmc); + memcached_st * + memcached_pool_destroy(memcached_pool_st* pool); + + memcached_st * + memcached_pool_pop (memcached_pool_st* pool, bool block, memcached_return_t *rc); + + memcached_return_t + memcached_pool_push(memcached_pool_st* pool, memcached_st *mmc); memcached_st *memcached_create (memcached_st *ptr); - memcached_return memcached_pool_behavior_set(memcached_pool_st *pool, - memcached_behavior flag, - uint64_t data) - memcached_return memcached_pool_behavior_get(memcached_pool_st *pool, - memcached_behavior flag, - uint64_t *value) + memcached_return_t + memcached_pool_behavior_set(memcached_pool_st *pool, + memcached_behavior_t flag, + uint64_t data) + + memcached_return_t + memcached_pool_behavior_get(memcached_pool_st *pool, + memcached_behavior_t flag, + uint64_t *value) =head1 DESCRIPTION @@ -46,7 +55,7 @@ passed as an argument to memcached_pool_create(), and returns the ownership of the pointer to the caller. memcached_pool_pop() is used to grab a connection structure from the -connection pool. The block argument specifies if the function should +connection pool. The block argument specifies if the function should block and wait for a connection structure to be available if we try to exceed the maximum size. @@ -67,7 +76,7 @@ memcached_st structure used to create the pool. If connections are in use it returns NULL. memcached_pool_pop() returns a pointer to a memcached_st structure -from the pool (or NULL if an allocation cannot be satisfied). +from the pool (or NULL if an allocation cannot be satisfied). memcached_pool_push() returns MEMCACHED_SUCCESS upon success. diff --git a/docs/memcached_result_st.pod b/docs/memcached_result_st.pod index 24631297..489b3f0e 100644 --- a/docs/memcached_result_st.pod +++ b/docs/memcached_result_st.pod @@ -14,33 +14,35 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_result_st *memcached_result_create(memcached_st *ptr, - memcached_result_st *result); + memcached_result_st * + memcached_result_create (memcached_st *ptr, + memcached_result_st *result); void memcached_result_free(memcached_result_st *result); - char * memcached_result_key_value(memcached_result_st *result); + char * memcached_result_key_value (memcached_result_st *result); - size_t memcached_result_key_length(memcached_result_st *result); + size_t memcached_result_key_length (memcached_result_st *result); - char *memcached_result_value(memcached_result_st *ptr); + char *memcached_result_value (memcached_result_st *ptr); - size_t memcached_result_length(memcached_result_st *ptr); + size_t memcached_result_length (memcached_result_st *ptr); - uint32_t memcached_result_flags(memcached_result_st *result) + uint32_t memcached_result_flags (memcached_result_st *result) - uint64_t memcached_result_cas(memcached_result_st *result); + uint64_t memcached_result_cas (memcached_result_st *result); - memcached_return memcached_result_set_value (memcached_result_st *ptr, - char *value, size_t length) + memcached_return_t + memcached_result_set_value (memcached_result_st *ptr, + char *value, size_t length) - void memcached_result_set_flags(memcached_result_st *ptr, uint32_t flags) + void memcached_result_set_flags (memcached_result_st *ptr, uint32_t flags) - void memcached_result_set_expiration(memcached_result_st *ptr, time_t) + void memcached_result_set_expiration (memcached_result_st *ptr, time_t) =head1 DESCRIPTION -libmemcached(3) can optionally return a memcached_result_st which acts as a +libmemcached(3) can optionally return a memcached_result_st which acts as a result object. The result objects have added benefits over the character pointer returns in that they are forward compatible with new return items that future memcached servers may implement (the best current example of @@ -64,13 +66,13 @@ memcached_result_key_length() returns the key length associated with the current result object. memcached_result_value() returns the result value associated with the -current result object. +current result object. memcached_result_length() returns the result length associated with the -current result object. +current result object. memcached_result_flags() returns the flags associated with the -current result object. +current result object. memcached_result_cas() returns the cas associated with the current result object. This value will only be available if the server @@ -82,15 +84,18 @@ the result to this value. This function is used for trigger responses. void memcached_result_set_flags() takes a result structure and stores a new value for the flags field. -void memcached_result_set_expiration(A) takes a result structure and stores +void memcached_result_set_expiration(A) takes a result structure and stores a new value for the expiration field (this is only used by read through triggers). +You may wish to avoid using memcached_result_create(3) with a +stack based allocation. The most common issues related to ABI safety involve +heap allocated structures. =head1 RETURN Varies, see particular functions. All structures must have -memcached_result_free() called on them for cleanup purposes. Failure to +memcached_result_free() called on them for cleanup purposes. Failure to do this will result in leaked memory. =head1 HOME diff --git a/docs/memcached_server_st.pod b/docs/memcached_server_st.pod index 08ff7785..912f0296 100644 --- a/docs/memcached_server_st.pod +++ b/docs/memcached_server_st.pod @@ -17,15 +17,15 @@ C Client Library for memcached (libmemcached, -lmemcached) memcached_server_list_append (memcached_server_st *ptr, const char *hostname, unsigned int port, - memcached_return *error); + memcached_return_t *error); unsigned int memcached_server_list_count (memcached_server_st *ptr); memcached_server_st *memcached_servers_parse (const char *server_strings); - const char *memcached_server_error(memcached_server_st *ptr); + const char *memcached_server_error (memcached_server_st *ptr); - void memcached_server_error_reset(memcached_server_st *ptr); + void memcached_server_error_reset (memcached_server_st *ptr); =head1 DESCRIPTION @@ -39,7 +39,7 @@ of memcached_server_st that you passed to it. memcached_server_list_append() adds a server to the end of a memcached_server_st array. On error null will be returned and the -memcached_return pointer you passed into the function will be set with the +memcached_return_t pointer you passed into the function will be set with the appropriate error. If the value of port is zero, it is set to the default port of a memcached server. diff --git a/docs/memcached_servers.pod b/docs/memcached_servers.pod index a4495382..80241c6a 100644 --- a/docs/memcached_servers.pod +++ b/docs/memcached_servers.pod @@ -15,28 +15,29 @@ C Client Library for memcached (libmemcached, -lmemcached) memcached_server_st * memcached_server_list (memcached_st *ptr); - memcached_return + memcached_return_t memcached_server_add (memcached_st *ptr, const char *hostname, - unsigned int port); + in_port_t port); - memcached_return + memcached_return_t memcached_server_add_udp (memcached_st *ptr, const char *hostname, - unsigned int port); + in_port_t port); - memcached_return + memcached_return_t memcached_server_add_unix_socket (memcached_st *ptr, const char *socket); - memcached_return + memcached_return_t memcached_server_push (memcached_st *ptr, memcached_server_st *list); memcached_server_st * memcached_server_by_key (memcached_st *ptr, const char *key, size_t key_length, - memcached_return *error); + memcached_return_t *error); + memcached_server_st * memcached_server_get_last_disconnect (memcached_st *ptr) diff --git a/docs/memcached_set.pod b/docs/memcached_set.pod index dadb9d2b..7a9ad04b 100644 --- a/docs/memcached_set.pod +++ b/docs/memcached_set.pod @@ -10,41 +10,41 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return + memcached_return_t memcached_set (memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); - memcached_return + memcached_return_t memcached_add (memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); - memcached_return + memcached_return_t memcached_replace (memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags); - memcached_return + memcached_return_t memcached_prepend(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) - memcached_return + memcached_return_t memcached_append(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, time_t expiration, uint32_t flags) - memcached_return + memcached_return_t memcached_cas(memcached_st *ptr, const char *key, size_t key_length, const char *value, size_t value_length, @@ -52,7 +52,7 @@ C Client Library for memcached (libmemcached, -lmemcached) uint32_t flags, uint64_t cas); - memcached_return + memcached_return_t memcached_set_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -60,7 +60,7 @@ C Client Library for memcached (libmemcached, -lmemcached) time_t expiration, uint32_t flags); - memcached_return + memcached_return_t memcached_add_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -68,7 +68,7 @@ C Client Library for memcached (libmemcached, -lmemcached) time_t expiration, uint32_t flags); - memcached_return + memcached_return_t memcached_replace_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -76,7 +76,7 @@ C Client Library for memcached (libmemcached, -lmemcached) time_t expiration, uint32_t flags); - memcached_return + memcached_return_t memcached_prepend_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -84,7 +84,7 @@ C Client Library for memcached (libmemcached, -lmemcached) time_t expiration, uint32_t flags); - memcached_return + memcached_return_t memcached_append_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -92,7 +92,7 @@ C Client Library for memcached (libmemcached, -lmemcached) time_t expiration, uint32_t flags); - memcached_return + memcached_return_t memcached_cas_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, @@ -163,7 +163,7 @@ will be returned. =head1 RETURN -All methods return a value of type C. +All methods return a value of type C. On success the value will be C. Use memcached_strerror() to translate this value to a printable string. diff --git a/docs/memcached_stats.pod b/docs/memcached_stats.pod index 26b0252f..a0741d3b 100644 --- a/docs/memcached_stats.pod +++ b/docs/memcached_stats.pod @@ -12,21 +12,23 @@ C Client Library for memcached (libmemcached, -lmemcached) memcached_stat_st *memcached_stat (memcached_st *ptr, char *args, - memcached_return *error); - - memcached_return memcached_stat_servername (memcached_stat_st *stat, - char *args, - char *hostname, - unsigned int port); - - char *memcached_stat_get_value (memcached_st *ptr, - memcached_stat_st *stat, - char *key, - memcached_return *error); - - char ** memcached_stat_get_keys (memcached_st *ptr, - memcached_stat_st *stat, - memcached_return *error); + memcached_return_t *error); + + memcached_return_t memcached_stat_servername (memcached_stat_st *stat, + char *args, + const char *hostname, + unsigned int port); + + char * + memcached_stat_get_value (memcached_st *ptr, + memcached_stat_st *stat, + const char *key, + memcached_return_t *error); + + char ** + memcached_stat_get_keys (memcached_st *ptr, + memcached_stat_st *stat, + memcached_return_t *error); =head1 DESCRIPTION diff --git a/docs/memcached_strerror.pod b/docs/memcached_strerror.pod index 7403685a..8386c312 100644 --- a/docs/memcached_strerror.pod +++ b/docs/memcached_strerror.pod @@ -10,24 +10,25 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - char *memcached_strerror (memcached_st *ptr, - memcached_return rc); + const char * + memcached_strerror (memcached_st *ptr, + memcached_return_t rc); =head1 DESCRIPTION -memcached_strerror() takes a C value and returns a string +memcached_strerror() takes a C value and returns a string describing the error. This string must not be modified by the application. -C values are returned from nearly all libmemcached(3) functions. +C values are returned from nearly all libmemcached(3) functions. -C values are of an enum type so that you can set up responses +C values are of an enum type so that you can set up responses with switch/case and know that you are capturing all possible return values. =head1 RETURN -memcached_strerror() returns a string describing a C value. +memcached_strerror() returns a string describing a C value. =head1 HOME diff --git a/docs/memcached_user_data.pod b/docs/memcached_user_data.pod index 66a25d11..597335ac 100644 --- a/docs/memcached_user_data.pod +++ b/docs/memcached_user_data.pod @@ -10,8 +10,9 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - void *memcached_get_user_data(memcached_st *ptr); - void *memcached_set_user_data(memcached_st *ptr, void *data); + void *memcached_get_user_data (memcached_st *ptr); + + void *memcached_set_user_data (memcached_st *ptr, void *data); =head1 DESCRIPTION diff --git a/docs/memcached_verbosity.pod b/docs/memcached_verbosity.pod index d7e1698b..475b66f2 100644 --- a/docs/memcached_verbosity.pod +++ b/docs/memcached_verbosity.pod @@ -10,8 +10,9 @@ C Client Library for memcached (libmemcached, -lmemcached) #include - memcached_return memcached_verbosity (memcached_st *ptr, - unsigned int verbosity); + memcached_return_t + memcached_verbosity (memcached_st *ptr, + unsigned int verbosity); =head1 DESCRIPTION @@ -20,7 +21,7 @@ memcached(1) servers referenced in the C parameter. =head1 RETURN -A value of type C is returned +A value of type C is returned On success that value will be C. Use memcached_strerror() to translate this value to a printable string. diff --git a/docs/memcached_version.pod b/docs/memcached_version.pod index 8307b2f3..3fbb8bf3 100644 --- a/docs/memcached_version.pod +++ b/docs/memcached_version.pod @@ -11,11 +11,11 @@ C Client Library for memcached (libmemcached, -lmemcached) #include const char * - memcached_lib_version(void) + memcached_lib_version (void) - memcached_return - memcached_version(memcached_st *ptr) + memcached_return_t + memcached_version (memcached_st *ptr) =head1 DESCRIPTION @@ -33,7 +33,7 @@ memcached server return code. A string with the version of libmemcached driver is returned from memcached_lib_version() -A value of type C is returned from memcached_version() +A value of type C is returned from memcached_version() On success that value will be C. If called with the C behavior set, the value C will be returned. Use memcached_strerror() to translate this value to diff --git a/example/interface_v1.c b/example/interface_v1.c index f52abfa2..2fcc0790 100644 --- a/example/interface_v1.c +++ b/example/interface_v1.c @@ -65,7 +65,8 @@ static protocol_binary_response_status append_handler(const void *cookie, const void* val, uint32_t vallen, uint64_t cas, - uint64_t *result_cas) { + uint64_t *result_cas) +{ (void)cookie; protocol_binary_response_status rval= PROTOCOL_BINARY_RESPONSE_SUCCESS; diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index 360739c5..66c142bf 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -21,6 +21,7 @@ noinst_HEADERS = libmemcached_probes.h \ pkginclude_HEADERS= memcached.h \ memcached.hpp \ exception.hpp \ + memcached_behavior.h \ memcached_configure.h \ memcached_constants.h \ memcached_get.h \ diff --git a/libmemcached/common.h b/libmemcached/common.h index 99d4ce78..596accaa 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -114,11 +114,11 @@ LIBMEMCACHED_LOCAL uint32_t jenkins_hash(const void *key, size_t length, uint32_t initval); LIBMEMCACHED_LOCAL -memcached_return memcached_connect(memcached_server_st *ptr); +memcached_return_t memcached_connect(memcached_server_st *ptr); LIBMEMCACHED_LOCAL -memcached_return memcached_response(memcached_server_st *ptr, - char *buffer, size_t buffer_length, - memcached_result_st *result); +memcached_return_t memcached_response(memcached_server_st *ptr, + char *buffer, size_t buffer_length, + memcached_result_st *result); LIBMEMCACHED_LOCAL void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death); @@ -127,29 +127,29 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death); #define memcached_server_response_reset(A) (A)->cursor_active=0 LIBMEMCACHED_LOCAL -memcached_return memcached_do(memcached_server_st *ptr, const void *commmand, - size_t command_length, uint8_t with_flush); +memcached_return_t memcached_do(memcached_server_st *ptr, const void *commmand, + size_t command_length, uint8_t with_flush); LIBMEMCACHED_LOCAL -memcached_return value_fetch(memcached_server_st *ptr, - char *buffer, - memcached_result_st *result); +memcached_return_t value_fetch(memcached_server_st *ptr, + char *buffer, + memcached_result_st *result); LIBMEMCACHED_LOCAL void server_list_free(memcached_st *ptr, memcached_server_st *servers); LIBMEMCACHED_LOCAL -memcached_return memcached_key_test(const char * const *keys, - const size_t *key_length, - size_t number_of_keys); +memcached_return_t memcached_key_test(const char * const *keys, + const size_t *key_length, + size_t number_of_keys); LIBMEMCACHED_LOCAL uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length); LIBMEMCACHED_LOCAL -memcached_return memcached_purge(memcached_server_st *ptr); +memcached_return_t memcached_purge(memcached_server_st *ptr); -static inline memcached_return memcached_validate_key_length(size_t key_length, - bool binary) { +static inline memcached_return_t memcached_validate_key_length(size_t key_length, bool binary) +{ unlikely (key_length == 0) return MEMCACHED_BAD_KEY_PROVIDED; diff --git a/libmemcached/memcached.c b/libmemcached/memcached.c index c5aff374..a363c249 100644 --- a/libmemcached/memcached.c +++ b/libmemcached/memcached.c @@ -74,7 +74,7 @@ void memcached_free(memcached_st *ptr) */ memcached_st *memcached_clone(memcached_st *clone, memcached_st *source) { - memcached_return rc= MEMCACHED_SUCCESS; + memcached_return_t rc= MEMCACHED_SUCCESS; memcached_st *new_clone; if (source == NULL) diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index efc81edf..a79e27ed 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -1,10 +1,13 @@ -/* +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * * Summary: interface for memcached server * Description: main include file for libmemcached * - * Copy: See Copyright for the status of this software. - * - * Author: Brian Aker */ #ifndef __MEMCACHED_H__ @@ -24,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -122,24 +126,24 @@ struct memcached_st { void *user_data; time_t next_distribution_rebuild; size_t prefix_key_length; - memcached_hash hash_continuum; + memcached_hash_t hash_continuum; memcached_result_st result; memcached_continuum_item_st *continuum; - memcached_clone_func on_clone; - memcached_cleanup_func on_cleanup; - memcached_free_function call_free; - memcached_malloc_function call_malloc; - memcached_realloc_function call_realloc; - memcached_calloc_function call_calloc; - memcached_trigger_key get_key_failure; - memcached_trigger_delete_key delete_trigger; + memcached_clone_fn on_clone; + memcached_cleanup_fn on_cleanup; + memcached_free_fn call_free; + memcached_malloc_fn call_malloc; + memcached_realloc_fn call_realloc; + memcached_calloc_fn call_calloc; + memcached_trigger_key_fn get_key_failure; + memcached_trigger_delete_key_fn delete_trigger; char prefix_key[MEMCACHED_PREFIX_KEY_MAX_SIZE]; uint32_t number_of_replicas; memcached_callback_st *callbacks; }; LIBMEMCACHED_API -memcached_return memcached_version(memcached_st *ptr); +memcached_return_t memcached_version(memcached_st *ptr); /* Public API */ @@ -154,35 +158,35 @@ LIBMEMCACHED_API memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr); LIBMEMCACHED_API -memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length, +memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length, time_t expiration); LIBMEMCACHED_API -memcached_return memcached_increment(memcached_st *ptr, +memcached_return_t memcached_increment(memcached_st *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value); LIBMEMCACHED_API -memcached_return memcached_decrement(memcached_st *ptr, +memcached_return_t memcached_decrement(memcached_st *ptr, const char *key, size_t key_length, uint32_t offset, uint64_t *value); LIBMEMCACHED_API -memcached_return memcached_increment_by_key(memcached_st *ptr, +memcached_return_t memcached_increment_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t *value); LIBMEMCACHED_API -memcached_return memcached_decrement_by_key(memcached_st *ptr, +memcached_return_t memcached_decrement_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, size_t key_length, uint64_t offset, uint64_t *value); LIBMEMCACHED_API -memcached_return memcached_increment_with_initial(memcached_st *ptr, +memcached_return_t memcached_increment_with_initial(memcached_st *ptr, const char *key, size_t key_length, uint64_t offset, @@ -190,7 +194,7 @@ memcached_return memcached_increment_with_initial(memcached_st *ptr, time_t expiration, uint64_t *value); LIBMEMCACHED_API -memcached_return memcached_decrement_with_initial(memcached_st *ptr, +memcached_return_t memcached_decrement_with_initial(memcached_st *ptr, const char *key, size_t key_length, uint64_t offset, @@ -198,7 +202,7 @@ memcached_return memcached_decrement_with_initial(memcached_st *ptr, time_t expiration, uint64_t *value); LIBMEMCACHED_API -memcached_return memcached_increment_with_initial_by_key(memcached_st *ptr, +memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, @@ -208,7 +212,7 @@ memcached_return memcached_increment_with_initial_by_key(memcached_st *ptr, time_t expiration, uint64_t *value); LIBMEMCACHED_API -memcached_return memcached_decrement_with_initial_by_key(memcached_st *ptr, +memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, @@ -219,125 +223,130 @@ memcached_return memcached_decrement_with_initial_by_key(memcached_st *ptr, uint64_t *value); LIBMEMCACHED_API void memcached_stat_free(memcached_st *, memcached_stat_st *); + LIBMEMCACHED_API -memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error); +memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error); + LIBMEMCACHED_API -memcached_return memcached_stat_servername(memcached_stat_st *memc_stat, char *args, - char *hostname, unsigned int port); +memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args, + const char *hostname, in_port_t port); + LIBMEMCACHED_API -memcached_return memcached_flush(memcached_st *ptr, time_t expiration); +memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration); + LIBMEMCACHED_API -memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity); +memcached_return_t memcached_verbosity(memcached_st *ptr, unsigned int verbosity); + LIBMEMCACHED_API void memcached_quit(memcached_st *ptr); + LIBMEMCACHED_API -const char *memcached_strerror(memcached_st *ptr, memcached_return rc); -LIBMEMCACHED_API -memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, uint64_t data); -LIBMEMCACHED_API -uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag); +const char *memcached_strerror(memcached_st *ptr, memcached_return_t rc); /* The two public hash bits */ LIBMEMCACHED_API -uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash hash_algorithm); +uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm); + LIBMEMCACHED_API uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length); LIBMEMCACHED_API -memcached_return memcached_flush_buffers(memcached_st *mem); +memcached_return_t memcached_flush_buffers(memcached_st *mem); /* Server Public functions */ LIBMEMCACHED_API -memcached_return memcached_server_add_udp(memcached_st *ptr, +memcached_return_t memcached_server_add_udp(memcached_st *ptr, const char *hostname, - unsigned int port); + in_port_t port); LIBMEMCACHED_API -memcached_return memcached_server_add_unix_socket(memcached_st *ptr, +memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr, const char *filename); LIBMEMCACHED_API -memcached_return memcached_server_add(memcached_st *ptr, const char *hostname, - unsigned int port); +memcached_return_t memcached_server_add(memcached_st *ptr, + const char *hostname, in_port_t port); LIBMEMCACHED_API -memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr, +memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr, const char *hostname, - unsigned int port, + in_port_t port, uint32_t weight); LIBMEMCACHED_API -memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr, +memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr, const char *filename, uint32_t weight); LIBMEMCACHED_API -memcached_return memcached_server_add_with_weight(memcached_st *ptr, const char *hostname, - unsigned int port, +memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, const char *hostname, + in_port_t port, uint32_t weight); LIBMEMCACHED_API void memcached_server_list_free(memcached_server_st *ptr); + LIBMEMCACHED_API -memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list); +memcached_return_t memcached_server_push(memcached_st *ptr, memcached_server_st *list); LIBMEMCACHED_API memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, const char *hostname, - unsigned int port, - memcached_return *error); + in_port_t port, + memcached_return_t *error); LIBMEMCACHED_API memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr, const char *hostname, - unsigned int port, + in_port_t port, uint32_t weight, - memcached_return *error); + memcached_return_t *error); LIBMEMCACHED_API unsigned int memcached_server_list_count(memcached_server_st *ptr); + LIBMEMCACHED_API memcached_server_st *memcached_servers_parse(const char *server_strings); LIBMEMCACHED_API char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat, - const char *key, memcached_return *error); + const char *key, memcached_return_t *error); LIBMEMCACHED_API char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat, - memcached_return *error); + memcached_return_t *error); LIBMEMCACHED_API -memcached_return memcached_delete_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - time_t expiration); +memcached_return_t memcached_delete_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + time_t expiration); LIBMEMCACHED_API -memcached_return memcached_fetch_execute(memcached_st *ptr, - memcached_execute_function *callback, - void *context, - unsigned int number_of_callbacks); +memcached_return_t memcached_fetch_execute(memcached_st *ptr, + memcached_execute_fn *callback, + void *context, + unsigned int number_of_callbacks); LIBMEMCACHED_API -memcached_return memcached_callback_set(memcached_st *ptr, - memcached_callback flag, - void *data); +memcached_return_t memcached_callback_set(memcached_st *ptr, + memcached_callback_t flag, + void *data); LIBMEMCACHED_API void *memcached_callback_get(memcached_st *ptr, - memcached_callback flag, - memcached_return *error); + memcached_callback_t flag, + memcached_return_t *error); LIBMEMCACHED_API -memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *function, void *context, uint32_t number_of_callbacks); +memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *function, void *context, uint32_t number_of_callbacks); LIBMEMCACHED_API -memcached_return memcached_set_memory_allocators(memcached_st *ptr, - memcached_malloc_function mem_malloc, - memcached_free_function mem_free, - memcached_realloc_function mem_realloc, - memcached_calloc_function mem_calloc); +memcached_return_t memcached_set_memory_allocators(memcached_st *ptr, + memcached_malloc_fn mem_malloc, + memcached_free_fn mem_free, + memcached_realloc_fn mem_realloc, + memcached_calloc_fn mem_calloc); LIBMEMCACHED_API void memcached_get_memory_allocators(memcached_st *ptr, - memcached_malloc_function *mem_malloc, - memcached_free_function *mem_free, - memcached_realloc_function *mem_realloc, - memcached_calloc_function *mem_calloc); + memcached_malloc_fn *mem_malloc, + memcached_free_fn *mem_free, + memcached_realloc_fn *mem_realloc, + memcached_calloc_fn *mem_calloc); LIBMEMCACHED_API void *memcached_get_user_data(memcached_st *ptr); @@ -345,7 +354,7 @@ LIBMEMCACHED_API void *memcached_set_user_data(memcached_st *ptr, void *data); LIBMEMCACHED_LOCAL -memcached_return run_distribution(memcached_st *ptr); +memcached_return_t run_distribution(memcached_st *ptr); #define memcached_is_allocated(__object) ((__object)->options.is_allocated) #define memcached_is_initialized(__object) ((__object)->options.is_initialized) diff --git a/libmemcached/memcached.hpp b/libmemcached/memcached.hpp index 107b01c5..c5acb3a9 100644 --- a/libmemcached/memcached.hpp +++ b/libmemcached/memcached.hpp @@ -36,8 +36,8 @@ class Memcache { public: - Memcache() - : + Memcache() + : servers_list(), memc(), servers(NULL), @@ -76,8 +76,8 @@ public: memcached_server_push(&memc, servers); } - Memcache(memcached_st *clone) - : + Memcache(memcached_st *clone) + : servers_list(), memc(), servers(NULL), @@ -134,23 +134,24 @@ public: /** * Return an error string for the given return structure. * - * @param[in] rc a memcached_return structure + * @param[in] rc a memcached_return_t structure * @return error string corresponding to given return code in the library. */ - const std::string getError(memcached_return rc) const + const std::string getError(memcached_return_t rc) const { /* first parameter to strerror is unused */ return memcached_strerror(NULL, rc); } - bool setBehavior(memcached_behavior flag, uint64_t data) { - memcached_return rc; + bool setBehavior(memcached_behavior_t flag, uint64_t data) + { + memcached_return_t rc; rc= memcached_behavior_set(&memc, flag, data); return (rc == MEMCACHED_SUCCESS); } - uint64_t getBehavior(memcached_behavior flag) { + uint64_t getBehavior(memcached_behavior_t flag) { return memcached_behavior_get(&memc, flag); } @@ -188,7 +189,7 @@ public: */ bool addServer(const std::string &server_name, unsigned int port) { - memcached_return rc; + memcached_return_t rc; std::ostringstream strstm; servers_list.append(","); servers_list.append(server_name); @@ -220,7 +221,7 @@ public: strstm << port; tmp_str.append(strstm.str()); memcached_server_st *server= memcached_servers_parse(tmp_str.c_str()); - memcached_return rc= memcached_server_remove(server); + memcached_return_t rc= memcached_server_remove(server); return (rc == MEMCACHED_SUCCESS); } @@ -232,13 +233,13 @@ public: * @param[out] ret_val store returned object in this vector * @return a memcached return structure */ - memcached_return fetch(std::string &key, + memcached_return_t fetch(std::string &key, std::vector &ret_val) { char ret_key[MEMCACHED_MAX_KEY]; size_t value_length= 0; size_t key_length= 0; - memcached_return rc; + memcached_return_t rc; uint32_t flags= 0; char *value= memcached_fetch(&memc, ret_key, &key_length, &value_length, &flags, &rc); @@ -265,11 +266,11 @@ public: * this vector * @return true on success; false otherwise */ - bool get(const std::string &key, + bool get(const std::string &key, std::vector &ret_val) throw (Error) { uint32_t flags= 0; - memcached_return rc; + memcached_return_t rc; size_t value_length= 0; if (key.empty()) @@ -291,7 +292,7 @@ public: /** * Fetches an individual from a server which is specified by * the master_key parameter that is used for determining which - * server an object was stored in if key partitioning was + * server an object was stored in if key partitioning was * used for storage. * * @param[in] master_key key that specifies server object is stored on @@ -300,12 +301,12 @@ public: * this vector * @return true on success; false otherwise */ - bool getByKey(const std::string &master_key, - const std::string &key, + bool getByKey(const std::string &master_key, + const std::string &key, std::vector &ret_val) throw(Error) { uint32_t flags= 0; - memcached_return rc; + memcached_return_t rc; size_t value_length= 0; if (master_key.empty() || key.empty()) @@ -356,12 +357,12 @@ public: } /* - * If the std::vector of keys is empty then we cannot + * If the std::vector of keys is empty then we cannot * call memcached_mget as we will get undefined behavior. */ if (! real_keys.empty()) { - memcached_return rc= memcached_mget(&memc, &real_keys[0], &key_len[0], + memcached_return_t rc= memcached_mget(&memc, &real_keys[0], &key_len[0], real_keys.size()); return (rc == MEMCACHED_SUCCESS); } @@ -389,7 +390,7 @@ public: { throw(Error("the key or value supplied is empty!", false)); } - memcached_return rc= memcached_set(&memc, + memcached_return_t rc= memcached_set(&memc, key.c_str(), key.length(), &value[0], value.size(), expiration, flags); @@ -407,8 +408,8 @@ public: * @param[in] flags flags to store with the object * @return true on succcess; false otherwise */ - bool setByKey(const std::string &master_key, - const std::string &key, + bool setByKey(const std::string &master_key, + const std::string &key, const std::vector &value, time_t expiration, uint32_t flags) throw(Error) @@ -419,7 +420,7 @@ public: { throw(Error("the key or value supplied is empty!", false)); } - memcached_return rc= memcached_set_by_key(&memc, master_key.c_str(), + memcached_return_t rc= memcached_set_by_key(&memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), &value[0], value.size(), @@ -513,7 +514,7 @@ public: { throw(Error("the key supplied is empty!", false)); } - memcached_return rc= memcached_increment(&memc, key.c_str(), key.length(), + memcached_return_t rc= memcached_increment(&memc, key.c_str(), key.length(), offset, value); return (rc == MEMCACHED_SUCCESS); } @@ -535,7 +536,7 @@ public: { throw(Error("the key supplied is empty!", false)); } - memcached_return rc= memcached_decrement(&memc, key.c_str(), + memcached_return_t rc= memcached_decrement(&memc, key.c_str(), key.length(), offset, value); return (rc == MEMCACHED_SUCCESS); @@ -557,7 +558,7 @@ public: { throw(Error("the key or value supplied is empty!", false)); } - memcached_return rc= memcached_add(&memc, key.c_str(), key.length(), + memcached_return_t rc= memcached_add(&memc, key.c_str(), key.length(), &value[0], value.size(), 0, 0); return (rc == MEMCACHED_SUCCESS); } @@ -572,22 +573,22 @@ public: * @param[in] value of object to add * @return true on success; false otherwise */ - bool addByKey(const std::string &master_key, - const std::string &key, + bool addByKey(const std::string &master_key, + const std::string &key, const std::vector &value) throw(Error) { if (master_key.empty() || - key.empty() || + key.empty() || value.empty()) { throw(Error("the master key or key supplied is empty!", false)); } - memcached_return rc= memcached_add_by_key(&memc, + memcached_return_t rc= memcached_add_by_key(&memc, master_key.c_str(), master_key.length(), key.c_str(), key.length(), - &value[0], + &value[0], value.size(), 0, 0); return (rc == MEMCACHED_SUCCESS); @@ -608,7 +609,7 @@ public: { throw(Error("the key or value supplied is empty!", false)); } - memcached_return rc= memcached_replace(&memc, key.c_str(), key.length(), + memcached_return_t rc= memcached_replace(&memc, key.c_str(), key.length(), &value[0], value.size(), 0, 0); return (rc == MEMCACHED_SUCCESS); @@ -624,8 +625,8 @@ public: * @param[in[ value value to replace object with * @return true on success; false otherwise */ - bool replaceByKey(const std::string &master_key, - const std::string &key, + bool replaceByKey(const std::string &master_key, + const std::string &key, const std::vector &value) { if (master_key.empty() || @@ -634,13 +635,13 @@ public: { throw(Error("the master key or key supplied is empty!", false)); } - memcached_return rc= memcached_replace_by_key(&memc, - master_key.c_str(), + memcached_return_t rc= memcached_replace_by_key(&memc, + master_key.c_str(), master_key.length(), - key.c_str(), + key.c_str(), key.length(), - &value[0], - value.size(), + &value[0], + value.size(), 0, 0); return (rc == MEMCACHED_SUCCESS); } @@ -659,7 +660,7 @@ public: { throw(Error("the key or value supplied is empty!", false)); } - memcached_return rc= memcached_prepend(&memc, key.c_str(), key.length(), + memcached_return_t rc= memcached_prepend(&memc, key.c_str(), key.length(), &value[0], value.size(), 0, 0); return (rc == MEMCACHED_SUCCESS); } @@ -674,8 +675,8 @@ public: * @param[in] value data to prepend to object's value * @return true on success; false otherwise */ - bool prependByKey(const std::string &master_key, - const std::string &key, + bool prependByKey(const std::string &master_key, + const std::string &key, const std::vector &value) throw(Error) { @@ -685,7 +686,7 @@ public: { throw(Error("the master key or key supplied is empty!", false)); } - memcached_return rc= memcached_prepend_by_key(&memc, + memcached_return_t rc= memcached_prepend_by_key(&memc, master_key.c_str(), master_key.length(), key.c_str(), @@ -711,7 +712,7 @@ public: { throw(Error("the key or value supplied is empty!", false)); } - memcached_return rc= memcached_append(&memc, + memcached_return_t rc= memcached_append(&memc, key.c_str(), key.length(), &value[0], @@ -741,13 +742,13 @@ public: { throw(Error("the master key or key supplied is empty!", false)); } - memcached_return rc= memcached_append_by_key(&memc, - master_key.c_str(), + memcached_return_t rc= memcached_append_by_key(&memc, + master_key.c_str(), master_key.length(), - key.c_str(), + key.c_str(), key.length(), - &value[0], - value.size(), + &value[0], + value.size(), 0, 0); return (rc == MEMCACHED_SUCCESS); } @@ -760,16 +761,16 @@ public: * @param[in] value value to store for object in server * @param[in] cas_arg "cas" value */ - bool cas(const std::string &key, - const std::vector &value, + bool cas(const std::string &key, + const std::vector &value, uint64_t cas_arg) throw(Error) { if (key.empty() || value.empty()) { throw(Error("the key or value supplied is empty!", false)); } - memcached_return rc= memcached_cas(&memc, key.c_str(), key.length(), - &value[0], value.size(), + memcached_return_t rc= memcached_cas(&memc, key.c_str(), key.length(), + &value[0], value.size(), 0, 0, cas_arg); return (rc == MEMCACHED_SUCCESS); } @@ -784,9 +785,9 @@ public: * @param[in] value value to store for object in server * @param[in] cas_arg "cas" value */ - bool casByKey(const std::string &master_key, - const std::string &key, - const std::vector &value, + bool casByKey(const std::string &master_key, + const std::string &key, + const std::vector &value, uint64_t cas_arg) throw(Error) { if (master_key.empty() || @@ -795,12 +796,12 @@ public: { throw(Error("the master key, key or value supplied is empty!", false)); } - memcached_return rc= memcached_cas_by_key(&memc, - master_key.c_str(), + memcached_return_t rc= memcached_cas_by_key(&memc, + master_key.c_str(), master_key.length(), - key.c_str(), + key.c_str(), key.length(), - &value[0], + &value[0], value.size(), 0, 0, cas_arg); return (rc == MEMCACHED_SUCCESS); @@ -818,7 +819,7 @@ public: { throw(Error("the key supplied is empty!", false)); } - memcached_return rc= memcached_delete(&memc, key.c_str(), key.length(), 0); + memcached_return_t rc= memcached_delete(&memc, key.c_str(), key.length(), 0); return (rc == MEMCACHED_SUCCESS); } @@ -836,7 +837,7 @@ public: { throw(Error("the key supplied is empty!", false)); } - memcached_return rc= memcached_delete(&memc, + memcached_return_t rc= memcached_delete(&memc, key.c_str(), key.length(), expiration); @@ -844,7 +845,7 @@ public: } /** - * Delete an object from the server specified by the key given. + * Delete an object from the server specified by the key given. * * @param[in] master_key specifies server to remove object from * @param[in] key key of object to delete @@ -857,7 +858,7 @@ public: { throw(Error("the master key or key supplied is empty!", false)); } - memcached_return rc= memcached_delete_by_key(&memc, + memcached_return_t rc= memcached_delete_by_key(&memc, master_key.c_str(), master_key.length(), key.c_str(), @@ -867,14 +868,14 @@ public: } /** - * Delete an object from the server specified by the key given. + * Delete an object from the server specified by the key given. * * @param[in] master_key specifies server to remove object from * @param[in] key key of object to delete * @param[in] expiration time to delete the object after * @return true on success; false otherwise */ - bool removeByKey(const std::string &master_key, + bool removeByKey(const std::string &master_key, const std::string &key, time_t expiration) throw(Error) { @@ -882,11 +883,11 @@ public: { throw(Error("the master key or key supplied is empty!", false)); } - memcached_return rc= memcached_delete_by_key(&memc, - master_key.c_str(), + memcached_return_t rc= memcached_delete_by_key(&memc, + master_key.c_str(), master_key.length(), - key.c_str(), - key.length(), + key.c_str(), + key.length(), expiration); return (rc == MEMCACHED_SUCCESS); } @@ -900,7 +901,7 @@ public: */ bool flush(time_t expiration) { - memcached_return rc= memcached_flush(&memc, expiration); + memcached_return_t rc= memcached_flush(&memc, expiration); return (rc == MEMCACHED_SUCCESS); } @@ -914,11 +915,11 @@ public: * @param[in] num_of_callbacks number of callback functions * @return true on success; false otherwise */ - bool fetchExecute(memcached_execute_function *callback, + bool fetchExecute(memcached_execute_fn *callback, void *context, - unsigned int num_of_callbacks) + uint32_t num_of_callbacks) { - memcached_return rc= memcached_fetch_execute(&memc, + memcached_return_t rc= memcached_fetch_execute(&memc, callback, context, num_of_callbacks); @@ -947,7 +948,7 @@ public: bool getStats(std::map< std::string, std::map > &stats_map) { - memcached_return rc; + memcached_return_t rc; memcached_stat_st *stats= memcached_stat(&memc, NULL, &rc); if (rc != MEMCACHED_SUCCESS && @@ -981,7 +982,7 @@ public: server_stats[*ptr]= value; free(value); } - + stats_map[server_name]= server_stats; free(list); } diff --git a/libmemcached/memcached_allocators.c b/libmemcached/memcached_allocators.c index bf57e357..767371cb 100644 --- a/libmemcached/memcached_allocators.c +++ b/libmemcached/memcached_allocators.c @@ -32,11 +32,11 @@ void *libmemcached_calloc(memcached_st *ptr, size_t nelem, size_t size) return calloc(nelem, size); } -memcached_return memcached_set_memory_allocators(memcached_st *ptr, - memcached_malloc_function mem_malloc, - memcached_free_function mem_free, - memcached_realloc_function mem_realloc, - memcached_calloc_function mem_calloc) +memcached_return_t memcached_set_memory_allocators(memcached_st *ptr, + memcached_malloc_fn mem_malloc, + memcached_free_fn mem_free, + memcached_realloc_fn mem_realloc, + memcached_calloc_fn mem_calloc) { /* All should be set, or none should be set */ if (mem_malloc == NULL && mem_free == NULL && mem_realloc == NULL && mem_calloc == NULL) @@ -60,10 +60,10 @@ memcached_return memcached_set_memory_allocators(memcached_st *ptr, } void memcached_get_memory_allocators(memcached_st *ptr, - memcached_malloc_function *mem_malloc, - memcached_free_function *mem_free, - memcached_realloc_function *mem_realloc, - memcached_calloc_function *mem_calloc) + memcached_malloc_fn *mem_malloc, + memcached_free_fn *mem_free, + memcached_realloc_fn *mem_realloc, + memcached_calloc_fn *mem_calloc) { *mem_malloc= ptr->call_malloc; *mem_free= ptr->call_free; diff --git a/libmemcached/memcached_analyze.c b/libmemcached/memcached_analyze.c index 61cea334..5c1c7e47 100644 --- a/libmemcached/memcached_analyze.c +++ b/libmemcached/memcached_analyze.c @@ -61,7 +61,7 @@ static void calc_hit_ratio(memcached_analysis_st *result, memcached_analysis_st *memcached_analyze(memcached_st *memc, memcached_stat_st *memc_stat, - memcached_return *error) + memcached_return_t *error) { uint64_t total_items= 0, total_bytes= 0; uint64_t total_get_cmds= 0, total_get_hits= 0; diff --git a/libmemcached/memcached_auto.c b/libmemcached/memcached_auto.c index b6355c15..b7466404 100644 --- a/libmemcached/memcached_auto.c +++ b/libmemcached/memcached_auto.c @@ -1,14 +1,25 @@ +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * + * Summary: Methods for adding or decrementing values from an object in memcached + * + */ + #include "common.h" -static memcached_return memcached_auto(memcached_st *ptr, - const char *verb, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - uint64_t offset, - uint64_t *value) +static memcached_return_t memcached_auto(memcached_st *ptr, + const char *verb, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + uint64_t offset, + uint64_t *value) { size_t send_length; - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; unsigned int server_key; bool no_reply= ptr->flags.no_reply; @@ -61,12 +72,12 @@ static memcached_return memcached_auto(memcached_st *ptr, return rc; } -static memcached_return binary_incr_decr(memcached_st *ptr, uint8_t cmd, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - uint64_t offset, uint64_t initial, - uint32_t expiration, - uint64_t *value) +static memcached_return_t binary_incr_decr(memcached_st *ptr, uint8_t cmd, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + uint64_t offset, uint64_t initial, + uint32_t expiration, + uint64_t *value) { unsigned int server_key; bool no_reply= ptr->flags.no_reply; @@ -108,29 +119,29 @@ static memcached_return binary_incr_decr(memcached_st *ptr, uint8_t cmd, return memcached_response(&ptr->hosts[server_key], (char*)value, sizeof(*value), NULL); } -memcached_return memcached_increment(memcached_st *ptr, - const char *key, size_t key_length, - uint32_t offset, - uint64_t *value) +memcached_return_t memcached_increment(memcached_st *ptr, + const char *key, size_t key_length, + uint32_t offset, + uint64_t *value) { return memcached_increment_by_key(ptr, key, key_length, key, key_length, offset, value); } -memcached_return memcached_decrement(memcached_st *ptr, - const char *key, size_t key_length, - uint32_t offset, - uint64_t *value) +memcached_return_t memcached_decrement(memcached_st *ptr, + const char *key, size_t key_length, + uint32_t offset, + uint64_t *value) { return memcached_decrement_by_key(ptr, key, key_length, key, key_length, offset, value); } -memcached_return memcached_increment_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - uint64_t offset, - uint64_t *value) +memcached_return_t memcached_increment_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + uint64_t offset, + uint64_t *value) { - memcached_return rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); + memcached_return_t rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); unlikely (rc != MEMCACHED_SUCCESS) return rc; @@ -152,13 +163,13 @@ memcached_return memcached_increment_by_key(memcached_st *ptr, return rc; } -memcached_return memcached_decrement_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - uint64_t offset, - uint64_t *value) +memcached_return_t memcached_decrement_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + uint64_t offset, + uint64_t *value) { - memcached_return rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); + memcached_return_t rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); unlikely (rc != MEMCACHED_SUCCESS) return rc; @@ -176,20 +187,20 @@ memcached_return memcached_decrement_by_key(memcached_st *ptr, return rc; } -memcached_return memcached_increment_with_initial(memcached_st *ptr, - const char *key, - size_t key_length, - uint64_t offset, - uint64_t initial, - time_t expiration, - uint64_t *value) +memcached_return_t memcached_increment_with_initial(memcached_st *ptr, + const char *key, + size_t key_length, + uint64_t offset, + uint64_t initial, + time_t expiration, + uint64_t *value) { return memcached_increment_with_initial_by_key(ptr, key, key_length, key, key_length, offset, initial, expiration, value); } -memcached_return memcached_increment_with_initial_by_key(memcached_st *ptr, +memcached_return_t memcached_increment_with_initial_by_key(memcached_st *ptr, const char *master_key, size_t master_key_length, const char *key, @@ -199,7 +210,7 @@ memcached_return memcached_increment_with_initial_by_key(memcached_st *ptr, time_t expiration, uint64_t *value) { - memcached_return rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); + memcached_return_t rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); unlikely (rc != MEMCACHED_SUCCESS) return rc; @@ -217,30 +228,30 @@ memcached_return memcached_increment_with_initial_by_key(memcached_st *ptr, return rc; } -memcached_return memcached_decrement_with_initial(memcached_st *ptr, - const char *key, - size_t key_length, - uint64_t offset, - uint64_t initial, - time_t expiration, - uint64_t *value) +memcached_return_t memcached_decrement_with_initial(memcached_st *ptr, + const char *key, + size_t key_length, + uint64_t offset, + uint64_t initial, + time_t expiration, + uint64_t *value) { return memcached_decrement_with_initial_by_key(ptr, key, key_length, key, key_length, offset, initial, expiration, value); } -memcached_return memcached_decrement_with_initial_by_key(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char *key, - size_t key_length, - uint64_t offset, - uint64_t initial, - time_t expiration, - uint64_t *value) +memcached_return_t memcached_decrement_with_initial_by_key(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char *key, + size_t key_length, + uint64_t offset, + uint64_t initial, + time_t expiration, + uint64_t *value) { - memcached_return rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); + memcached_return_t rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); unlikely (rc != MEMCACHED_SUCCESS) return rc; diff --git a/libmemcached/memcached_behavior.c b/libmemcached/memcached_behavior.c index e434893f..3553c173 100644 --- a/libmemcached/memcached_behavior.c +++ b/libmemcached/memcached_behavior.c @@ -1,3 +1,14 @@ +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * + * Summary: Change the behavior of the memcached connection. + * + */ + #include "common.h" #include #include @@ -10,9 +21,9 @@ We quit all connections so we can reset the sockets. */ -memcached_return memcached_behavior_set(memcached_st *ptr, - memcached_behavior flag, - uint64_t data) +memcached_return_t memcached_behavior_set(memcached_st *ptr, + memcached_behavior_t flag, + uint64_t data) { switch (flag) { @@ -69,7 +80,7 @@ memcached_return memcached_behavior_set(memcached_st *ptr, break; case MEMCACHED_BEHAVIOR_DISTRIBUTION: { - ptr->distribution= (memcached_server_distribution)(data); + ptr->distribution= (memcached_server_distribution_t)(data); if (ptr->distribution == MEMCACHED_DISTRIBUTION_RANDOM) { srandom((uint32_t) time(NULL)); @@ -118,13 +129,13 @@ memcached_return memcached_behavior_set(memcached_st *ptr, break; case MEMCACHED_BEHAVIOR_HASH: #ifndef HAVE_HSIEH_HASH - if ((memcached_hash)(data) == MEMCACHED_HASH_HSIEH) + if ((memcached_hash_t)(data) == MEMCACHED_HASH_HSIEH) return MEMCACHED_FAILURE; #endif - ptr->hash= (memcached_hash)(data); + ptr->hash= (memcached_hash_t)(data); break; case MEMCACHED_BEHAVIOR_KETAMA_HASH: - ptr->hash_continuum= (memcached_hash)(data); + ptr->hash_continuum= (memcached_hash_t)(data); run_distribution(ptr); break; case MEMCACHED_BEHAVIOR_CACHE_LOOKUPS: @@ -185,7 +196,7 @@ memcached_return memcached_behavior_set(memcached_st *ptr, } uint64_t memcached_behavior_get(memcached_st *ptr, - memcached_behavior flag) + memcached_behavior_t flag) { switch (flag) { diff --git a/libmemcached/memcached_callback.c b/libmemcached/memcached_callback.c index ea59f844..618bedf4 100644 --- a/libmemcached/memcached_callback.c +++ b/libmemcached/memcached_callback.c @@ -7,9 +7,9 @@ These functions provide data and function callback support */ -memcached_return memcached_callback_set(memcached_st *ptr, - memcached_callback flag, - void *data) +memcached_return_t memcached_callback_set(memcached_st *ptr, + memcached_callback_t flag, + void *data) { switch (flag) { @@ -52,13 +52,13 @@ memcached_return memcached_callback_set(memcached_st *ptr, } case MEMCACHED_CALLBACK_CLEANUP_FUNCTION: { - memcached_cleanup_func func= *(memcached_cleanup_func *)&data; + memcached_cleanup_fn func= *(memcached_cleanup_fn *)&data; ptr->on_cleanup= func; break; } case MEMCACHED_CALLBACK_CLONE_FUNCTION: { - memcached_clone_func func= *(memcached_clone_func *)&data; + memcached_clone_fn func= *(memcached_clone_fn *)&data; ptr->on_clone= func; break; } @@ -84,13 +84,13 @@ memcached_return memcached_callback_set(memcached_st *ptr, #endif case MEMCACHED_CALLBACK_GET_FAILURE: { - memcached_trigger_key func= *(memcached_trigger_key *)&data; + memcached_trigger_key_fn func= *(memcached_trigger_key_fn *)&data; ptr->get_key_failure= func; break; } case MEMCACHED_CALLBACK_DELETE_TRIGGER: { - memcached_trigger_delete_key func= *(memcached_trigger_delete_key *)&data; + memcached_trigger_delete_key_fn func= *(memcached_trigger_delete_key_fn *)&data; ptr->delete_trigger= func; break; } @@ -102,10 +102,10 @@ memcached_return memcached_callback_set(memcached_st *ptr, } void *memcached_callback_get(memcached_st *ptr, - memcached_callback flag, - memcached_return *error) + memcached_callback_t flag, + memcached_return_t *error) { - memcached_return local_error; + memcached_return_t local_error; if (!error) error = &local_error; @@ -168,8 +168,8 @@ void *memcached_callback_get(memcached_st *ptr, return *(void **)&ptr->delete_trigger; } default: - WATCHPOINT_ASSERT(0); - *error= MEMCACHED_FAILURE; - return NULL; + WATCHPOINT_ASSERT(0); + *error= MEMCACHED_FAILURE; + return NULL; } } diff --git a/libmemcached/memcached_connect.c b/libmemcached/memcached_connect.c index 67f76bc4..24328f4c 100644 --- a/libmemcached/memcached_connect.c +++ b/libmemcached/memcached_connect.c @@ -3,7 +3,7 @@ #include #include -static memcached_return set_hostinfo(memcached_server_st *server) +static memcached_return_t set_hostinfo(memcached_server_st *server) { struct addrinfo *ai; struct addrinfo hints; @@ -44,7 +44,7 @@ static memcached_return set_hostinfo(memcached_server_st *server) return MEMCACHED_SUCCESS; } -static memcached_return set_socket_options(memcached_server_st *ptr) +static memcached_return_t set_socket_options(memcached_server_st *ptr) { WATCHPOINT_ASSERT(ptr->fd != -1); @@ -145,7 +145,7 @@ static memcached_return set_socket_options(memcached_server_st *ptr) return MEMCACHED_SUCCESS; } -static memcached_return unix_socket_connect(memcached_server_st *ptr) +static memcached_return_t unix_socket_connect(memcached_server_st *ptr) { struct sockaddr_un servAddr; socklen_t addrlen; @@ -189,7 +189,7 @@ test_connect: return MEMCACHED_SUCCESS; } -static memcached_return network_connect(memcached_server_st *ptr) +static memcached_return_t network_connect(memcached_server_st *ptr) { if (ptr->fd == -1) { @@ -198,7 +198,7 @@ static memcached_return network_connect(memcached_server_st *ptr) if (!ptr->sockaddr_inited || (!(ptr->root->flags.use_cache_lookups))) { - memcached_return rc; + memcached_return_t rc; rc= set_hostinfo(ptr); if (rc != MEMCACHED_SUCCESS) @@ -299,9 +299,9 @@ static memcached_return network_connect(memcached_server_st *ptr) } -memcached_return memcached_connect(memcached_server_st *ptr) +memcached_return_t memcached_connect(memcached_server_st *ptr) { - memcached_return rc= MEMCACHED_NO_SERVERS; + memcached_return_t rc= MEMCACHED_NO_SERVERS; LIBMEMCACHED_MEMCACHED_CONNECT_START(); /* both retry_timeout and server_failure_limit must be set in order to delay retrying a server on error. */ diff --git a/libmemcached/memcached_constants.h b/libmemcached/memcached_constants.h index b19f03c7..09c6040c 100644 --- a/libmemcached/memcached_constants.h +++ b/libmemcached/memcached_constants.h @@ -65,7 +65,8 @@ typedef enum { MEMCACHED_E2BIG, MEMCACHED_INVALID_ARGUMENTS, MEMCACHED_MAXIMUM_RETURN /* Always add new error code before */ -} memcached_return; +} memcached_return_t; + typedef enum { MEMCACHED_DISTRIBUTION_MODULA, @@ -73,7 +74,7 @@ typedef enum { MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA, MEMCACHED_DISTRIBUTION_RANDOM, MEMCACHED_DISTRIBUTION_CONSISTENT_KETAMA_SPY -} memcached_server_distribution; +} memcached_server_distribution_t; typedef enum { MEMCACHED_BEHAVIOR_NO_BLOCK, @@ -108,7 +109,7 @@ typedef enum { MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, MEMCACHED_BEHAVIOR_KETAMA_COMPAT_MODE, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ -} memcached_behavior; +} memcached_behavior_t; #define MEMCACHED_KETAMA_COMPAT_LIBMEMCACHED 0 #define MEMCACHED_KETAMA_COMPAT_SPY 1 @@ -125,7 +126,7 @@ typedef enum { #endif MEMCACHED_CALLBACK_GET_FAILURE = 7, MEMCACHED_CALLBACK_DELETE_TRIGGER = 8 -} memcached_callback; +} memcached_callback_t; typedef enum { MEMCACHED_HASH_DEFAULT= 0, @@ -138,13 +139,13 @@ typedef enum { MEMCACHED_HASH_HSIEH, MEMCACHED_HASH_MURMUR, MEMCACHED_HASH_JENKINS -} memcached_hash; +} memcached_hash_t; typedef enum { MEMCACHED_CONNECTION_UNKNOWN, MEMCACHED_CONNECTION_TCP, MEMCACHED_CONNECTION_UDP, MEMCACHED_CONNECTION_UNIX_SOCKET -} memcached_connection; +} memcached_connection_t; #endif /* __MEMCACHED_CONSTANTS_H__ */ diff --git a/libmemcached/memcached_delete.c b/libmemcached/memcached_delete.c index e2b77a54..bbdd2527 100644 --- a/libmemcached/memcached_delete.c +++ b/libmemcached/memcached_delete.c @@ -1,27 +1,27 @@ #include "common.h" #include "memcached/protocol_binary.h" -memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length, - time_t expiration) +memcached_return_t memcached_delete(memcached_st *ptr, const char *key, size_t key_length, + time_t expiration) { return memcached_delete_by_key(ptr, key, key_length, key, key_length, expiration); } -static inline memcached_return binary_delete(memcached_st *ptr, - unsigned int server_key, - const char *key, - size_t key_length, - uint8_t flush); +static inline memcached_return_t binary_delete(memcached_st *ptr, + unsigned int server_key, + const char *key, + size_t key_length, + uint8_t flush); -memcached_return memcached_delete_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - time_t expiration) +memcached_return_t memcached_delete_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + time_t expiration) { uint8_t to_write; size_t send_length; - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; unsigned int server_key; @@ -124,11 +124,11 @@ error: return rc; } -static inline memcached_return binary_delete(memcached_st *ptr, - unsigned int server_key, - const char *key, - size_t key_length, - uint8_t flush) +static inline memcached_return_t binary_delete(memcached_st *ptr, + unsigned int server_key, + const char *key, + size_t key_length, + uint8_t flush) { protocol_binary_request_delete request= {.bytes= {0}}; @@ -150,7 +150,7 @@ static inline memcached_return binary_delete(memcached_st *ptr, memcached_io_write(&ptr->hosts[server_key], NULL, 0, 1); } - memcached_return rc= MEMCACHED_SUCCESS; + memcached_return_t rc= MEMCACHED_SUCCESS; if ((memcached_do(&ptr->hosts[server_key], request.bytes, sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) || diff --git a/libmemcached/memcached_do.c b/libmemcached/memcached_do.c index db359534..d673f187 100644 --- a/libmemcached/memcached_do.c +++ b/libmemcached/memcached_do.c @@ -1,9 +1,9 @@ #include "common.h" -memcached_return memcached_do(memcached_server_st *ptr, const void *command, - size_t command_length, uint8_t with_flush) +memcached_return_t memcached_do(memcached_server_st *ptr, const void *command, + size_t command_length, uint8_t with_flush) { - memcached_return rc; + memcached_return_t rc; ssize_t sent_length; WATCHPOINT_ASSERT(command_length); diff --git a/libmemcached/memcached_dump.c b/libmemcached/memcached_dump.c index 1f60bade..4c1006e7 100644 --- a/libmemcached/memcached_dump.c +++ b/libmemcached/memcached_dump.c @@ -7,9 +7,9 @@ */ #include "common.h" -static memcached_return ascii_dump(memcached_st *ptr, memcached_dump_func *callback, void *context, uint32_t number_of_callbacks) +static memcached_return_t ascii_dump(memcached_st *ptr, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks) { - memcached_return rc= 0; + memcached_return_t rc= 0; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; size_t send_length; uint32_t server_key; @@ -80,7 +80,7 @@ error: return rc; } -memcached_return memcached_dump(memcached_st *ptr, memcached_dump_func *callback, void *context, uint32_t number_of_callbacks) +memcached_return_t memcached_dump(memcached_st *ptr, memcached_dump_fn *callback, void *context, uint32_t number_of_callbacks) { /* No support for Binary protocol yet */ if (ptr->flags.binary_protocol) diff --git a/libmemcached/memcached_fetch.c b/libmemcached/memcached_fetch.c index bf97b0bd..dbb1ff62 100644 --- a/libmemcached/memcached_fetch.c +++ b/libmemcached/memcached_fetch.c @@ -4,7 +4,7 @@ char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, uint32_t *flags, - memcached_return *error) + memcached_return_t *error) { memcached_result_st *result_buffer= &ptr->result; @@ -41,7 +41,7 @@ char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, - memcached_return *error) + memcached_return_t *error) { memcached_server_st *server; @@ -81,13 +81,13 @@ memcached_result_st *memcached_fetch_result(memcached_st *ptr, return NULL; } -memcached_return memcached_fetch_execute(memcached_st *ptr, - memcached_execute_function *callback, - void *context, - unsigned int number_of_callbacks) +memcached_return_t memcached_fetch_execute(memcached_st *ptr, + memcached_execute_fn *callback, + void *context, + uint32_t number_of_callbacks) { memcached_result_st *result= &ptr->result; - memcached_return rc= MEMCACHED_FAILURE; + memcached_return_t rc= MEMCACHED_FAILURE; unsigned int x; while ((result= memcached_fetch_result(ptr, result, &rc)) != NULL) diff --git a/libmemcached/memcached_flush.c b/libmemcached/memcached_flush.c index fe737eed..d05d7442 100644 --- a/libmemcached/memcached_flush.c +++ b/libmemcached/memcached_flush.c @@ -1,13 +1,13 @@ #include "common.h" -static memcached_return memcached_flush_binary(memcached_st *ptr, - time_t expiration); -static memcached_return memcached_flush_textual(memcached_st *ptr, - time_t expiration); +static memcached_return_t memcached_flush_binary(memcached_st *ptr, + time_t expiration); +static memcached_return_t memcached_flush_textual(memcached_st *ptr, + time_t expiration); -memcached_return memcached_flush(memcached_st *ptr, time_t expiration) +memcached_return_t memcached_flush(memcached_st *ptr, time_t expiration) { - memcached_return rc; + memcached_return_t rc; LIBMEMCACHED_MEMCACHED_FLUSH_START(); if (ptr->flags.binary_protocol) @@ -18,12 +18,12 @@ memcached_return memcached_flush(memcached_st *ptr, time_t expiration) return rc; } -static memcached_return memcached_flush_textual(memcached_st *ptr, - time_t expiration) +static memcached_return_t memcached_flush_textual(memcached_st *ptr, + time_t expiration) { unsigned int x; size_t send_length; - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; unlikely (ptr->number_of_hosts == 0) @@ -50,8 +50,8 @@ static memcached_return memcached_flush_textual(memcached_st *ptr, return MEMCACHED_SUCCESS; } -static memcached_return memcached_flush_binary(memcached_st *ptr, - time_t expiration) +static memcached_return_t memcached_flush_binary(memcached_st *ptr, + time_t expiration) { unsigned int x; protocol_binary_request_flush request= {.bytes= {0}}; @@ -83,7 +83,7 @@ static memcached_return memcached_flush_binary(memcached_st *ptr, for (x= 0; x < ptr->number_of_hosts; x++) { if (memcached_server_response_count(&ptr->hosts[x]) > 0) - (void)memcached_response(&ptr->hosts[x], NULL, 0, NULL); + (void)memcached_response(&ptr->hosts[x], NULL, 0, NULL); } return MEMCACHED_SUCCESS; diff --git a/libmemcached/memcached_flush_buffers.c b/libmemcached/memcached_flush_buffers.c index bbf09549..f001e21e 100644 --- a/libmemcached/memcached_flush_buffers.c +++ b/libmemcached/memcached_flush_buffers.c @@ -1,9 +1,9 @@ #include "common.h" #include "memcached_io.h" -memcached_return memcached_flush_buffers(memcached_st *mem) +memcached_return_t memcached_flush_buffers(memcached_st *mem) { - memcached_return ret= MEMCACHED_SUCCESS; + memcached_return_t ret= MEMCACHED_SUCCESS; for (uint32_t x= 0; x < mem->number_of_hosts; ++x) if (mem->hosts[x].write_buffer_offset != 0) diff --git a/libmemcached/memcached_get.c b/libmemcached/memcached_get.c index a3a56501..094c65b8 100644 --- a/libmemcached/memcached_get.c +++ b/libmemcached/memcached_get.c @@ -8,19 +8,19 @@ char *memcached_get(memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, - memcached_return *error) + memcached_return_t *error) { return memcached_get_by_key(ptr, NULL, 0, key, key_length, value_length, flags, error); } -static memcached_return memcached_mget_by_key_real(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - bool mget_mode); +static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + bool mget_mode); char *memcached_get_by_key(memcached_st *ptr, const char *master_key, @@ -28,12 +28,12 @@ char *memcached_get_by_key(memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, - memcached_return *error) + memcached_return_t *error) { char *value; size_t dummy_length; uint32_t dummy_flags; - memcached_return dummy_error; + memcached_return_t dummy_error; unlikely (ptr->flags.use_udp) { @@ -56,7 +56,7 @@ char *memcached_get_by_key(memcached_st *ptr, { if (ptr->get_key_failure && *error == MEMCACHED_NOTFOUND) { - memcached_return rc; + memcached_return_t rc; memcached_result_reset(&ptr->result); rc= ptr->get_key_failure(ptr, key, key_length, &ptr->result); @@ -108,38 +108,38 @@ char *memcached_get_by_key(memcached_st *ptr, return value; } -memcached_return memcached_mget(memcached_st *ptr, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys) +memcached_return_t memcached_mget(memcached_st *ptr, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys) { return memcached_mget_by_key(ptr, NULL, 0, keys, key_length, number_of_keys); } -static memcached_return binary_mget_by_key(memcached_st *ptr, - unsigned int master_server_key, - bool is_master_key_set, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - bool mget_mode); - -static memcached_return memcached_mget_by_key_real(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - bool mget_mode) +static memcached_return_t binary_mget_by_key(memcached_st *ptr, + unsigned int master_server_key, + bool is_master_key_set, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + bool mget_mode); + +static memcached_return_t memcached_mget_by_key_real(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + bool mget_mode) { unsigned int x; - memcached_return rc= MEMCACHED_NOTFOUND; + memcached_return_t rc= MEMCACHED_NOTFOUND; const char *get_command= "get "; uint8_t get_command_length= 4; unsigned int master_server_key= (unsigned int)-1; /* 0 is a valid server id! */ bool is_master_key_set= false; - unlikely (ptr->flags.use_udp) + unlikely (ptr->flags.use_udp) return MEMCACHED_NOT_SUPPORTED; LIBMEMCACHED_MEMCACHED_MGET_START(); @@ -267,44 +267,44 @@ static memcached_return memcached_mget_by_key_real(memcached_st *ptr, return rc; } -memcached_return memcached_mget_by_key(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys) +memcached_return_t memcached_mget_by_key(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys) { return memcached_mget_by_key_real(ptr, master_key, master_key_length, keys, key_length, number_of_keys, true); } -memcached_return memcached_mget_execute(memcached_st *ptr, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - memcached_execute_function *callback, - void *context, - unsigned int number_of_callbacks) +memcached_return_t memcached_mget_execute(memcached_st *ptr, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_fn *callback, + void *context, + unsigned int number_of_callbacks) { return memcached_mget_execute_by_key(ptr, NULL, 0, keys, key_length, number_of_keys, callback, context, number_of_callbacks); } -memcached_return memcached_mget_execute_by_key(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - memcached_execute_function *callback, - void *context, - unsigned int number_of_callbacks) +memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_fn *callback, + void *context, + unsigned int number_of_callbacks) { if ((ptr->flags.binary_protocol) == 0) return MEMCACHED_NOT_SUPPORTED; - memcached_return rc; + memcached_return_t rc; memcached_callback_st *original_callbacks= ptr->callbacks; memcached_callback_st cb= { .callback= callback, @@ -319,14 +319,14 @@ memcached_return memcached_mget_execute_by_key(memcached_st *ptr, return rc; } -static memcached_return simple_binary_mget(memcached_st *ptr, - unsigned int master_server_key, - bool is_master_key_set, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, bool mget_mode) +static memcached_return_t simple_binary_mget(memcached_st *ptr, + unsigned int master_server_key, + bool is_master_key_set, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, bool mget_mode) { - memcached_return rc= MEMCACHED_NOTFOUND; + memcached_return_t rc= MEMCACHED_NOTFOUND; uint32_t x; int flush= number_of_keys == 1; @@ -358,7 +358,7 @@ static memcached_return simple_binary_mget(memcached_st *ptr, else request.message.header.request.opcode= PROTOCOL_BINARY_CMD_GETK; - memcached_return vk; + memcached_return_t vk; vk= memcached_validate_key_length(key_length[x], ptr->flags.binary_protocol); unlikely (vk != MEMCACHED_SUCCESS) @@ -394,7 +394,7 @@ static memcached_return simple_binary_mget(memcached_st *ptr, { /* * Send a noop command to flush the buffers - */ + */ protocol_binary_request_noop request= {.bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; request.message.header.request.opcode= PROTOCOL_BINARY_CMD_NOOP; @@ -411,32 +411,32 @@ static memcached_return simple_binary_mget(memcached_st *ptr, } if (memcached_io_write(&ptr->hosts[x], request.bytes, - sizeof(request.bytes), 1) == -1) + sizeof(request.bytes), 1) == -1) { memcached_server_response_reset(&ptr->hosts[x]); memcached_io_reset(&ptr->hosts[x]); rc= MEMCACHED_SOME_ERRORS; } } - } + } return rc; } -static memcached_return replication_binary_mget(memcached_st *ptr, - uint32_t* hash, - bool* dead_servers, - const char *const *keys, - const size_t *key_length, - size_t number_of_keys) +static memcached_return_t replication_binary_mget(memcached_st *ptr, + uint32_t* hash, + bool* dead_servers, + const char *const *keys, + const size_t *key_length, + size_t number_of_keys) { - memcached_return rc= MEMCACHED_NOTFOUND; + memcached_return_t rc= MEMCACHED_NOTFOUND; uint32_t x, start= 0; uint64_t randomize_read= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ); if (randomize_read) - start= (uint32_t)random() % (uint32_t)(ptr->number_of_replicas + 1); + start= (uint32_t)random() % (uint32_t)(ptr->number_of_replicas + 1); /* Loop for each replica */ for (uint32_t replica= 0; replica <= ptr->number_of_replicas; ++replica) @@ -491,7 +491,7 @@ static memcached_return replication_binary_mget(memcached_st *ptr, * and we used the callback interface from memcached_mget_execute so * that we might have processed some of the responses etc. For now, * just make sure we work _correctly_ - */ + */ if ((memcached_io_write(&ptr->hosts[server], request.bytes, sizeof(request.bytes), 0) == -1) || (memcached_io_write(&ptr->hosts[server], keys[x], @@ -514,15 +514,15 @@ static memcached_return replication_binary_mget(memcached_st *ptr, return rc; } -static memcached_return binary_mget_by_key(memcached_st *ptr, - unsigned int master_server_key, - bool is_master_key_set, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - bool mget_mode) +static memcached_return_t binary_mget_by_key(memcached_st *ptr, + unsigned int master_server_key, + bool is_master_key_set, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + bool mget_mode) { - memcached_return rc; + memcached_return_t rc; if (ptr->number_of_replicas == 0) { diff --git a/libmemcached/memcached_get.h b/libmemcached/memcached_get.h index bf3aeb53..905f9857 100644 --- a/libmemcached/memcached_get.h +++ b/libmemcached/memcached_get.h @@ -19,13 +19,13 @@ char *memcached_get(memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, - memcached_return *error); + memcached_return_t *error); LIBMEMCACHED_API -memcached_return memcached_mget(memcached_st *ptr, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys); +memcached_return_t memcached_mget(memcached_st *ptr, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys); LIBMEMCACHED_API char *memcached_get_by_key(memcached_st *ptr, @@ -33,46 +33,46 @@ char *memcached_get_by_key(memcached_st *ptr, const char *key, size_t key_length, size_t *value_length, uint32_t *flags, - memcached_return *error); + memcached_return_t *error); LIBMEMCACHED_API -memcached_return memcached_mget_by_key(memcached_st *ptr, - const char *master_key, size_t - master_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys); +memcached_return_t memcached_mget_by_key(memcached_st *ptr, + const char *master_key, size_t + master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys); LIBMEMCACHED_API char *memcached_fetch(memcached_st *ptr, char *key, size_t *key_length, size_t *value_length, uint32_t *flags, - memcached_return *error); + memcached_return_t *error); LIBMEMCACHED_API memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, - memcached_return *error); + memcached_return_t *error); LIBMEMCACHED_API -memcached_return memcached_mget_execute(memcached_st *ptr, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - memcached_execute_function *callback, - void *context, - unsigned int number_of_callbacks); +memcached_return_t memcached_mget_execute(memcached_st *ptr, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_fn *callback, + void *context, + unsigned int number_of_callbacks); LIBMEMCACHED_API -memcached_return memcached_mget_execute_by_key(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char * const *keys, - const size_t *key_length, - size_t number_of_keys, - memcached_execute_function *callback, - void *context, - unsigned int number_of_callbacks); +memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char * const *keys, + const size_t *key_length, + size_t number_of_keys, + memcached_execute_fn *callback, + void *context, + unsigned int number_of_callbacks); #ifdef __cplusplus } diff --git a/libmemcached/memcached_hash.c b/libmemcached/memcached_hash.c index 04eeb553..395020a3 100644 --- a/libmemcached/memcached_hash.c +++ b/libmemcached/memcached_hash.c @@ -12,7 +12,7 @@ static uint32_t FNV_32_PRIME= 16777619; static uint32_t internal_generate_hash(const char *key, size_t key_length); static uint32_t internal_generate_md5(const char *key, size_t key_length); -uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash hash_algorithm) +uint32_t memcached_generate_hash_value(const char *key, size_t key_length, memcached_hash_t hash_algorithm) { uint32_t hash= 1; /* Just here to remove compile warning */ uint32_t x= 0; diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index 75c84fcf..8cc5f3e6 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -2,11 +2,11 @@ #include /* Protoypes (static) */ -static memcached_return server_add(memcached_st *ptr, const char *hostname, - unsigned int port, - uint32_t weight, - memcached_connection type); -memcached_return update_continuum(memcached_st *ptr); +static memcached_return_t server_add(memcached_st *ptr, const char *hostname, + in_port_t port, + uint32_t weight, + memcached_connection_t type); +memcached_return_t update_continuum(memcached_st *ptr); static int compare_servers(const void *p1, const void *p2) { @@ -34,7 +34,7 @@ static void sort_hosts(memcached_st *ptr) } -memcached_return run_distribution(memcached_st *ptr) +memcached_return_t run_distribution(memcached_st *ptr) { switch (ptr->distribution) { @@ -103,7 +103,7 @@ static int continuum_item_cmp(const void *t1, const void *t2) return -1; } -memcached_return update_continuum(memcached_st *ptr) +memcached_return_t update_continuum(memcached_st *ptr) { uint32_t host_index; uint32_t continuum_index= 0; @@ -306,7 +306,7 @@ memcached_return update_continuum(memcached_st *ptr) } -memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *list) +memcached_return_t memcached_server_push(memcached_st *ptr, memcached_server_st *list) { unsigned int x; uint16_t count; @@ -343,15 +343,15 @@ memcached_return memcached_server_push(memcached_st *ptr, memcached_server_st *l return run_distribution(ptr); } -memcached_return memcached_server_add_unix_socket(memcached_st *ptr, - const char *filename) +memcached_return_t memcached_server_add_unix_socket(memcached_st *ptr, + const char *filename) { return memcached_server_add_unix_socket_with_weight(ptr, filename, 0); } -memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr, - const char *filename, - uint32_t weight) +memcached_return_t memcached_server_add_unix_socket_with_weight(memcached_st *ptr, + const char *filename, + uint32_t weight) { if (!filename) return MEMCACHED_FAILURE; @@ -359,17 +359,17 @@ memcached_return memcached_server_add_unix_socket_with_weight(memcached_st *ptr, return server_add(ptr, filename, 0, weight, MEMCACHED_CONNECTION_UNIX_SOCKET); } -memcached_return memcached_server_add_udp(memcached_st *ptr, - const char *hostname, - unsigned int port) +memcached_return_t memcached_server_add_udp(memcached_st *ptr, + const char *hostname, + in_port_t port) { return memcached_server_add_udp_with_weight(ptr, hostname, port, 0); } -memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr, - const char *hostname, - unsigned int port, - uint32_t weight) +memcached_return_t memcached_server_add_udp_with_weight(memcached_st *ptr, + const char *hostname, + in_port_t port, + uint32_t weight) { if (!port) port= MEMCACHED_DEFAULT_PORT; @@ -380,17 +380,17 @@ memcached_return memcached_server_add_udp_with_weight(memcached_st *ptr, return server_add(ptr, hostname, port, weight, MEMCACHED_CONNECTION_UDP); } -memcached_return memcached_server_add(memcached_st *ptr, - const char *hostname, - unsigned int port) +memcached_return_t memcached_server_add(memcached_st *ptr, + const char *hostname, + in_port_t port) { return memcached_server_add_with_weight(ptr, hostname, port, 0); } -memcached_return memcached_server_add_with_weight(memcached_st *ptr, - const char *hostname, - unsigned int port, - uint32_t weight) +memcached_return_t memcached_server_add_with_weight(memcached_st *ptr, + const char *hostname, + in_port_t port, + uint32_t weight) { if (!port) port= MEMCACHED_DEFAULT_PORT; @@ -401,10 +401,10 @@ memcached_return memcached_server_add_with_weight(memcached_st *ptr, return server_add(ptr, hostname, port, weight, MEMCACHED_CONNECTION_TCP); } -static memcached_return server_add(memcached_st *ptr, const char *hostname, - unsigned int port, - uint32_t weight, - memcached_connection type) +static memcached_return_t server_add(memcached_st *ptr, const char *hostname, + in_port_t port, + uint32_t weight, + memcached_connection_t type) { memcached_server_st *new_host_list; @@ -428,7 +428,7 @@ static memcached_return server_add(memcached_st *ptr, const char *hostname, return run_distribution(ptr); } -memcached_return memcached_server_remove(memcached_server_st *st_ptr) +memcached_return_t memcached_server_remove(memcached_server_st *st_ptr) { uint32_t x, host_index; memcached_st *ptr= st_ptr->root; @@ -456,16 +456,16 @@ memcached_return memcached_server_remove(memcached_server_st *st_ptr) } memcached_server_st *memcached_server_list_append(memcached_server_st *ptr, - const char *hostname, unsigned int port, - memcached_return *error) + const char *hostname, in_port_t port, + memcached_return_t *error) { return memcached_server_list_append_with_weight(ptr, hostname, port, 0, error); } memcached_server_st *memcached_server_list_append_with_weight(memcached_server_st *ptr, - const char *hostname, unsigned int port, + const char *hostname, in_port_t port, uint32_t weight, - memcached_return *error) + memcached_return_t *error) { unsigned int count; memcached_server_st *new_host_list; diff --git a/libmemcached/memcached_io.c b/libmemcached/memcached_io.c index c74e2cdf..fe534c90 100644 --- a/libmemcached/memcached_io.c +++ b/libmemcached/memcached_io.c @@ -12,15 +12,15 @@ typedef enum { MEM_WRITE } memc_read_or_write; -static ssize_t io_flush(memcached_server_st *ptr, memcached_return *error); +static ssize_t io_flush(memcached_server_st *ptr, memcached_return_t *error); static void increment_udp_message_id(memcached_server_st *ptr); -static memcached_return io_wait(memcached_server_st *ptr, - memc_read_or_write read_or_write) +static memcached_return_t io_wait(memcached_server_st *ptr, + memc_read_or_write read_or_write) { struct pollfd fds= { - .fd= ptr->fd, - .events = POLLIN + .fd= ptr->fd, + .events = POLLIN }; int error; @@ -28,16 +28,16 @@ static memcached_return io_wait(memcached_server_st *ptr, fds.events= POLLOUT; /* - ** We are going to block on write, but at least on Solaris we might block - ** on write if we haven't read anything from our input buffer.. - ** Try to purge the input buffer if we don't do any flow control in the - ** application layer (just sending a lot of data etc) - ** The test is moved down in the purge function to avoid duplication of - ** the test. - */ + ** We are going to block on write, but at least on Solaris we might block + ** on write if we haven't read anything from our input buffer.. + ** Try to purge the input buffer if we don't do any flow control in the + ** application layer (just sending a lot of data etc) + ** The test is moved down in the purge function to avoid duplication of + ** the test. + */ if (read_or_write == MEM_WRITE) { - memcached_return rc= memcached_purge(ptr); + memcached_return_t rc= memcached_purge(ptr); if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED) return MEMCACHED_FAILURE; } @@ -71,8 +71,8 @@ static bool repack_input_buffer(memcached_server_st *ptr) if (ptr->read_ptr != ptr->read_buffer) { /* Move all of the data to the beginning of the buffer so - ** that we can fit more data into the buffer... - */ + ** that we can fit more data into the buffer... + */ memmove(ptr->read_buffer, ptr->read_ptr, ptr->read_buffer_length); ptr->read_ptr= ptr->read_buffer; ptr->read_data_length= ptr->read_buffer_length; @@ -109,19 +109,19 @@ static bool repack_input_buffer(memcached_server_st *ptr) static bool process_input_buffer(memcached_server_st *ptr) { /* - ** We might be able to process some of the response messages if we - ** have a callback set up - */ + ** We might be able to process some of the response messages if we + ** have a callback set up + */ if (ptr->root->callbacks != NULL && ptr->root->flags.use_udp == false) { /* * We might have responses... try to read them out and fire * callbacks - */ + */ memcached_callback_st cb= *ptr->root->callbacks; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; - memcached_return error; + memcached_return_t error; error= memcached_response(ptr, buffer, sizeof(buffer), &ptr->root->result); if (error == MEMCACHED_SUCCESS) @@ -169,8 +169,8 @@ void memcached_io_preread(memcached_st *ptr) } #endif -memcached_return memcached_io_read(memcached_server_st *ptr, - void *buffer, size_t length, ssize_t *nread) +memcached_return_t memcached_io_read(memcached_server_st *ptr, + void *buffer, size_t length, ssize_t *nread) { char *buffer_ptr; @@ -190,14 +190,14 @@ memcached_return memcached_io_read(memcached_server_st *ptr, else if (data_read == -1) { ptr->cached_errno= errno; - memcached_return rc= MEMCACHED_UNKNOWN_READ_FAILURE; + memcached_return_t rc= MEMCACHED_UNKNOWN_READ_FAILURE; switch (errno) { case EAGAIN: case EINTR: if ((rc= io_wait(ptr, MEM_READ)) == MEMCACHED_SUCCESS) continue; - /* fall through */ + /* fall through */ default: { @@ -297,7 +297,7 @@ ssize_t memcached_io_write(memcached_server_st *ptr, if (ptr->write_buffer_offset == buffer_end && ptr->type != MEMCACHED_CONNECTION_UDP) { - memcached_return rc; + memcached_return_t rc; ssize_t sent_length; WATCHPOINT_ASSERT(ptr->fd != -1); @@ -315,7 +315,7 @@ ssize_t memcached_io_write(memcached_server_st *ptr, if (with_flush) { - memcached_return rc; + memcached_return_t rc; WATCHPOINT_ASSERT(ptr->fd != -1); if (io_flush(ptr, &rc) == -1) return -1; @@ -324,7 +324,7 @@ ssize_t memcached_io_write(memcached_server_st *ptr, return (ssize_t) original_length; } -memcached_return memcached_io_close(memcached_server_st *ptr) +memcached_return_t memcached_io_close(memcached_server_st *ptr) { int r; @@ -406,20 +406,20 @@ memcached_server_st *memcached_io_get_readable_server(memcached_st *memc) } static ssize_t io_flush(memcached_server_st *ptr, - memcached_return *error) + memcached_return_t *error) { /* - ** We might want to purge the input buffer if we haven't consumed - ** any output yet... The test for the limits is the purge is inline - ** in the purge function to avoid duplicating the logic.. - */ + ** We might want to purge the input buffer if we haven't consumed + ** any output yet... The test for the limits is the purge is inline + ** in the purge function to avoid duplicating the logic.. + */ { - memcached_return rc; - WATCHPOINT_ASSERT(ptr->fd != -1); - rc= memcached_purge(ptr); + memcached_return_t rc; + WATCHPOINT_ASSERT(ptr->fd != -1); + rc= memcached_purge(ptr); - if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED) - return -1; + if (rc != MEMCACHED_SUCCESS && rc != MEMCACHED_STORED) + return -1; } ssize_t sent_length; size_t return_length; @@ -435,7 +435,7 @@ static ssize_t io_flush(memcached_server_st *ptr, return -1; if (ptr->write_buffer_offset == 0 || (ptr->type == MEMCACHED_CONNECTION_UDP - && ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH)) + && ptr->write_buffer_offset == UDP_DATAGRAM_HEADER_LENGTH)) return 0; /* Looking for memory overflows */ @@ -463,26 +463,26 @@ static ssize_t io_flush(memcached_server_st *ptr, case ENOBUFS: continue; case EAGAIN: - { - /* - * We may be blocked on write because the input buffer - * is full. Let's check if we have room in our input - * buffer for more data and retry the write before - * waiting.. + { + /* + * We may be blocked on write because the input buffer + * is full. Let's check if we have room in our input + * buffer for more data and retry the write before + * waiting.. */ - if (repack_input_buffer(ptr) || - process_input_buffer(ptr)) - continue; + if (repack_input_buffer(ptr) || + process_input_buffer(ptr)) + continue; - memcached_return rc; - rc= io_wait(ptr, MEM_WRITE); + memcached_return_t rc; + rc= io_wait(ptr, MEM_WRITE); - if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_TIMEOUT) - continue; + if (rc == MEMCACHED_SUCCESS || rc == MEMCACHED_TIMEOUT) + continue; - memcached_quit_server(ptr, 1); - return -1; - } + memcached_quit_server(ptr, 1); + return -1; + } default: memcached_quit_server(ptr, 1); *error= MEMCACHED_ERRNO; @@ -530,9 +530,9 @@ void memcached_io_reset(memcached_server_st *ptr) * Read a given number of bytes from the server and place it into a specific * buffer. Reset the IO channel on this server if an error occurs. */ -memcached_return memcached_safe_read(memcached_server_st *ptr, - void *dta, - size_t size) +memcached_return_t memcached_safe_read(memcached_server_st *ptr, + void *dta, + size_t size) { size_t offset= 0; char *data= dta; @@ -540,8 +540,8 @@ memcached_return memcached_safe_read(memcached_server_st *ptr, while (offset < size) { ssize_t nread; - memcached_return rc= memcached_io_read(ptr, data + offset, size - offset, - &nread); + memcached_return_t rc= memcached_io_read(ptr, data + offset, size - offset, + &nread); if (rc != MEMCACHED_SUCCESS) return rc; @@ -551,9 +551,9 @@ memcached_return memcached_safe_read(memcached_server_st *ptr, return MEMCACHED_SUCCESS; } -memcached_return memcached_io_readline(memcached_server_st *ptr, - char *buffer_ptr, - size_t size) +memcached_return_t memcached_io_readline(memcached_server_st *ptr, + char *buffer_ptr, + size_t size) { bool line_complete= false; size_t total_nr= 0; @@ -566,9 +566,9 @@ memcached_return memcached_io_readline(memcached_server_st *ptr, * We don't have any data in the buffer, so let's fill the read * buffer. Call the standard read function to avoid duplicating * the logic. - */ + */ ssize_t nread; - memcached_return rc= memcached_io_read(ptr, buffer_ptr, 1, &nread); + memcached_return_t rc= memcached_io_read(ptr, buffer_ptr, 1, &nread); if (rc != MEMCACHED_SUCCESS) return rc; @@ -622,7 +622,7 @@ static void increment_udp_message_id(memcached_server_st *ptr) header->request_id= htons((uint16_t) (thread_id | msg_num)); } -memcached_return memcached_io_init_udp_header(memcached_server_st *ptr, uint16_t thread_id) +memcached_return_t memcached_io_init_udp_header(memcached_server_st *ptr, uint16_t thread_id) { if (thread_id > UDP_REQUEST_ID_MAX_THREAD_ID) return MEMCACHED_FAILURE; diff --git a/libmemcached/memcached_io.h b/libmemcached/memcached_io.h index da253955..03d63b55 100644 --- a/libmemcached/memcached_io.h +++ b/libmemcached/memcached_io.h @@ -1,14 +1,21 @@ -/* - * Summary: Server IO, Not public! +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. * - * Copy: See Copyright for the status of this software. + * Summary: Server IO, Not public! * - * Author: Brian Aker */ #ifndef LIBMEMCACHED_MEMCACHED_IO_H #define LIBMEMCACHED_MEMCACHED_IO_H +#ifdef __cplusplus +extern "C" { +#endif + #if defined(BUILDING_LIBMEMCACHED) #include "libmemcached/memcached.h" @@ -35,25 +42,30 @@ struct udp_datagram_header_st { ssize_t memcached_io_write(memcached_server_st *ptr, const void *buffer, size_t length, char with_flush); void memcached_io_reset(memcached_server_st *ptr); -memcached_return memcached_io_read(memcached_server_st *ptr, - void *buffer, size_t length, ssize_t *nread); +memcached_return_t memcached_io_read(memcached_server_st *ptr, + void *buffer, size_t length, ssize_t *nread); /* Read a line (terminated by '\n') into the buffer */ -memcached_return memcached_io_readline(memcached_server_st *ptr, - char *buffer_ptr, - size_t size); -memcached_return memcached_io_close(memcached_server_st *ptr); +memcached_return_t memcached_io_readline(memcached_server_st *ptr, + char *buffer_ptr, + size_t size); +memcached_return_t memcached_io_close(memcached_server_st *ptr); /* Read n bytes of data from the server and store them in dta */ -memcached_return memcached_safe_read(memcached_server_st *ptr, - void *dta, - size_t size); +memcached_return_t memcached_safe_read(memcached_server_st *ptr, + void *dta, + size_t size); /* Read a single response from the server */ -memcached_return memcached_read_one_response(memcached_server_st *ptr, - char *buffer, size_t buffer_length, - memcached_result_st *result); -memcached_return memcached_io_init_udp_header(memcached_server_st *ptr, - uint16_t thread_id); +memcached_return_t memcached_read_one_response(memcached_server_st *ptr, + char *buffer, size_t buffer_length, + memcached_result_st *result); +memcached_return_t memcached_io_init_udp_header(memcached_server_st *ptr, + uint16_t thread_id); memcached_server_st *memcached_io_get_readable_server(memcached_st *memc); #endif /* BUILDING_LIBMEMCACHED */ + +#ifdef __cplusplus +} +#endif + #endif /* LIBMEMCACHED_MEMCACHED_IO_H */ diff --git a/libmemcached/memcached_key.c b/libmemcached/memcached_key.c index 9aac1ebc..3b16b273 100644 --- a/libmemcached/memcached_key.c +++ b/libmemcached/memcached_key.c @@ -1,11 +1,11 @@ #include "common.h" -memcached_return memcached_key_test(const char * const *keys, - const size_t *key_length, - size_t number_of_keys) +memcached_return_t memcached_key_test(const char * const *keys, + const size_t *key_length, + size_t number_of_keys) { uint32_t x; - memcached_return rc; + memcached_return_t rc; for (x= 0; x < number_of_keys; x++) { diff --git a/libmemcached/memcached_parse.c b/libmemcached/memcached_parse.c index ec695cfa..73cc9dfe 100644 --- a/libmemcached/memcached_parse.c +++ b/libmemcached/memcached_parse.c @@ -15,7 +15,7 @@ memcached_server_st *memcached_servers_parse(const char *server_strings) const char *begin_ptr; const char *end_ptr; memcached_server_st *servers= NULL; - memcached_return rc; + memcached_return_t rc; WATCHPOINT_ASSERT(server_strings); diff --git a/libmemcached/memcached_pool.h b/libmemcached/memcached_pool.h index 03fc0e3a..967d768d 100644 --- a/libmemcached/memcached_pool.h +++ b/libmemcached/memcached_pool.h @@ -26,15 +26,19 @@ memcached_st* memcached_pool_destroy(memcached_pool_st* pool); LIBMEMCACHED_API memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, - memcached_return* rc); + memcached_return_t* rc); LIBMEMCACHED_API -memcached_return memcached_pool_push(memcached_pool_st* pool, +memcached_return_t memcached_pool_push(memcached_pool_st* pool, memcached_st* mmc); LIBMEMCACHED_API -memcached_return memcached_pool_behavior_set(memcached_pool_st *ptr, memcached_behavior flag, uint64_t data); +memcached_return_t memcached_pool_behavior_set(memcached_pool_st *ptr, + memcached_behavior_t flag, + uint64_t data); LIBMEMCACHED_API -memcached_return memcached_pool_behavior_get(memcached_pool_st *ptr, memcached_behavior flag, uint64_t *value); +memcached_return_t memcached_pool_behavior_get(memcached_pool_st *ptr, + memcached_behavior_t flag, + uint64_t *value); #ifdef __cplusplus } diff --git a/libmemcached/memcached_purge.c b/libmemcached/memcached_purge.c index 1f47e59e..9042142b 100644 --- a/libmemcached/memcached_purge.c +++ b/libmemcached/memcached_purge.c @@ -2,27 +2,27 @@ #include "memcached_io.h" #include "memcached_constants.h" -memcached_return memcached_purge(memcached_server_st *ptr) +memcached_return_t memcached_purge(memcached_server_st *ptr) { uint32_t x; - memcached_return ret= MEMCACHED_SUCCESS; + memcached_return_t ret= MEMCACHED_SUCCESS; if (ptr->root->options.is_purging || /* already purging */ (memcached_server_response_count(ptr) < ptr->root->io_msg_watermark && - ptr->io_bytes_sent < ptr->root->io_bytes_watermark) || + ptr->io_bytes_sent < ptr->root->io_bytes_watermark) || (ptr->io_bytes_sent >= ptr->root->io_bytes_watermark && - memcached_server_response_count(ptr) < 2)) + memcached_server_response_count(ptr) < 2)) { return MEMCACHED_SUCCESS; } /* memcached_io_write and memcached_response may call memcached_purge - so we need to be able stop any recursion.. */ + so we need to be able stop any recursion.. */ ptr->root->options.is_purging= true; WATCHPOINT_ASSERT(ptr->fd != -1); /* Force a flush of the buffer to ensure that we don't have the n-1 pending - requests buffered up.. */ + requests buffered up.. */ if (memcached_io_write(ptr, NULL, 0, 1) == -1) { ptr->root->options.is_purging= true; @@ -41,7 +41,7 @@ memcached_return memcached_purge(memcached_server_st *ptr) * We need to increase the timeout, because we might be waiting for * data to be sent from the server (the commands was in the output buffer * and just flushed - */ + */ int32_t timeo= ptr->root->poll_timeout; ptr->root->poll_timeout= 2000; @@ -51,14 +51,14 @@ memcached_return memcached_purge(memcached_server_st *ptr) for (x= 0; x < no_msg; x++) { memcached_result_reset(result_ptr); - memcached_return rc= memcached_read_one_response(ptr, buffer, - sizeof (buffer), - result_ptr); + memcached_return_t rc= memcached_read_one_response(ptr, buffer, + sizeof (buffer), + result_ptr); /* * Purge doesn't care for what kind of command results that is received. * The only kind of errors I care about if is I'm out of sync with the * protocol or have problems reading data from the network.. - */ + */ if (rc== MEMCACHED_PROTOCOL_ERROR || rc == MEMCACHED_UNKNOWN_READ_FAILURE) { WATCHPOINT_ERROR(rc); diff --git a/libmemcached/memcached_quit.c b/libmemcached/memcached_quit.c index ba306ccc..3c117ade 100644 --- a/libmemcached/memcached_quit.c +++ b/libmemcached/memcached_quit.c @@ -15,7 +15,7 @@ void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death) { if (io_death == 0 && ptr->type != MEMCACHED_CONNECTION_UDP) { - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_MAX_BUFFER]; if (ptr->root->flags.binary_protocol) diff --git a/libmemcached/memcached_response.c b/libmemcached/memcached_response.c index 81cb341a..cb297428 100644 --- a/libmemcached/memcached_response.c +++ b/libmemcached/memcached_response.c @@ -8,14 +8,14 @@ #include "common.h" #include "memcached_io.h" -static memcached_return textual_read_one_response(memcached_server_st *ptr, +static memcached_return_t textual_read_one_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result); -static memcached_return binary_read_one_response(memcached_server_st *ptr, +static memcached_return_t binary_read_one_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result); -memcached_return memcached_read_one_response(memcached_server_st *ptr, +memcached_return_t memcached_read_one_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result) { @@ -24,7 +24,7 @@ memcached_return memcached_read_one_response(memcached_server_st *ptr, if (result == NULL) result = &ptr->root->result; - memcached_return rc; + memcached_return_t rc; if (ptr->root->flags.binary_protocol) rc= binary_read_one_response(ptr, buffer, buffer_length, result); else @@ -39,7 +39,7 @@ memcached_return memcached_read_one_response(memcached_server_st *ptr, return rc; } -memcached_return memcached_response(memcached_server_st *ptr, +memcached_return_t memcached_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result) { @@ -55,7 +55,7 @@ memcached_return memcached_response(memcached_server_st *ptr, if (ptr->root->flags.binary_protocol == false) while (memcached_server_response_count(ptr) > 1) { - memcached_return rc= memcached_read_one_response(ptr, buffer, buffer_length, result); + memcached_return_t rc= memcached_read_one_response(ptr, buffer, buffer_length, result); unlikely (rc != MEMCACHED_END && rc != MEMCACHED_STORED && @@ -71,11 +71,11 @@ memcached_return memcached_response(memcached_server_st *ptr, return memcached_read_one_response(ptr, buffer, buffer_length, result); } -static memcached_return textual_value_fetch(memcached_server_st *ptr, +static memcached_return_t textual_value_fetch(memcached_server_st *ptr, char *buffer, memcached_result_st *result) { - memcached_return rc= MEMCACHED_SUCCESS; + memcached_return_t rc= MEMCACHED_SUCCESS; char *string_ptr; char *end_ptr; char *next_ptr; @@ -175,7 +175,7 @@ static memcached_return textual_value_fetch(memcached_server_st *ptr, */ to_read= (value_length) + 2; ssize_t read_length= 0; - memcached_return rrc= memcached_io_read(ptr, value_ptr, to_read, &read_length); + memcached_return_t rrc= memcached_io_read(ptr, value_ptr, to_read, &read_length); if (rrc != MEMCACHED_SUCCESS) return rrc; @@ -201,11 +201,11 @@ read_error: return MEMCACHED_PARTIAL_READ; } -static memcached_return textual_read_one_response(memcached_server_st *ptr, +static memcached_return_t textual_read_one_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result) { - memcached_return rc= memcached_io_readline(ptr, buffer, buffer_length); + memcached_return_t rc= memcached_io_readline(ptr, buffer, buffer_length); if (rc != MEMCACHED_SUCCESS) return rc; @@ -330,7 +330,7 @@ size_t memcached_result_length(memcached_result_st *ptr) return memcached_string_length(sptr); } -static memcached_return binary_read_one_response(memcached_server_st *ptr, +static memcached_return_t binary_read_one_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result) { @@ -489,7 +489,7 @@ static memcached_return binary_read_one_response(memcached_server_st *ptr, } } - memcached_return rc= MEMCACHED_SUCCESS; + memcached_return_t rc= MEMCACHED_SUCCESS; unlikely(header.response.status != 0) switch (header.response.status) { diff --git a/libmemcached/memcached_result.c b/libmemcached/memcached_result.c index 6fdad670..6427f1df 100644 --- a/libmemcached/memcached_result.c +++ b/libmemcached/memcached_result.c @@ -47,7 +47,7 @@ void memcached_result_reset(memcached_result_st *ptr) /* NOTE turn into macro */ -memcached_return memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length) +memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length) { return memcached_string_append(&ptr->value, value, length); } diff --git a/libmemcached/memcached_result.h b/libmemcached/memcached_result.h index 88212824..aeea59cc 100644 --- a/libmemcached/memcached_result.h +++ b/libmemcached/memcached_result.h @@ -51,7 +51,7 @@ size_t memcached_result_length(memcached_result_st *ptr); #define memcached_result_flags(A) (A)->flags #define memcached_result_cas(A) (A)->cas LIBMEMCACHED_API -memcached_return memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length); +memcached_return_t memcached_result_set_value(memcached_result_st *ptr, const char *value, size_t length); #define memcached_result_set_flags(A,B) (A)->flags=(B) #define memcached_result_set_expiration(A,B) (A)->expiration=(B) diff --git a/libmemcached/memcached_server.c b/libmemcached/memcached_server.c index 03e76ac4..5a94e767 100644 --- a/libmemcached/memcached_server.c +++ b/libmemcached/memcached_server.c @@ -25,8 +25,8 @@ memcached_server_st *memcached_server_create(memcached_st *memc, memcached_serve } memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host, - const char *hostname, unsigned int port, - uint32_t weight, memcached_connection type) + const char *hostname, in_port_t port, + uint32_t weight, memcached_connection_t type) { host= memcached_server_create(memc, host); @@ -97,10 +97,10 @@ memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcache } -memcached_return memcached_server_cursor(memcached_st *ptr, - memcached_server_function *callback, - void *context, - unsigned int number_of_callbacks) +memcached_return_t memcached_server_cursor(memcached_st *ptr, + memcached_server_fn *callback, + void *context, + uint32_t number_of_callbacks) { unsigned int y; @@ -122,7 +122,7 @@ memcached_return memcached_server_cursor(memcached_st *ptr, return MEMCACHED_SUCCESS; } -memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key, size_t key_length, memcached_return *error) +memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key, size_t key_length, memcached_return_t *error) { uint32_t server_key; diff --git a/libmemcached/memcached_server.h b/libmemcached/memcached_server.h index cd110442..e0fc7ea1 100644 --- a/libmemcached/memcached_server.h +++ b/libmemcached/memcached_server.h @@ -29,7 +29,7 @@ struct memcached_server_st { uint8_t major_version; uint8_t micro_version; uint8_t minor_version; - memcached_connection type; + memcached_connection_t type; char *read_ptr; char *cached_server_error; size_t read_buffer_length; @@ -51,14 +51,14 @@ struct memcached_server_st { #define memcached_server_response_count(A) (A)->cursor_active LIBMEMCACHED_API -memcached_return memcached_server_cursor(memcached_st *ptr, - memcached_server_function *callback, - void *context, - unsigned int number_of_callbacks); +memcached_return_t memcached_server_cursor(memcached_st *ptr, + memcached_server_fn *callback, + void *context, + uint32_t number_of_callbacks); LIBMEMCACHED_API memcached_server_st *memcached_server_by_key(memcached_st *ptr, const char *key, - size_t key_length, memcached_return *error); + size_t key_length, memcached_return_t *error); LIBMEMCACHED_API const char *memcached_server_error(memcached_server_st *ptr); @@ -74,8 +74,8 @@ memcached_server_st *memcached_server_create(memcached_st *memc, memcached_serve LIBMEMCACHED_API memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host, - const char *hostname, unsigned int port, - uint32_t weight, memcached_connection type); + const char *hostname, in_port_t port, + uint32_t weight, memcached_connection_t type); LIBMEMCACHED_API void memcached_server_free(memcached_server_st *ptr); @@ -83,10 +83,10 @@ LIBMEMCACHED_API memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr); LIBMEMCACHED_API memcached_analysis_st *memcached_analyze(memcached_st *memc, memcached_stat_st *memc_stat, - memcached_return *error); + memcached_return_t *error); LIBMEMCACHED_API -memcached_return memcached_server_remove(memcached_server_st *st_ptr); +memcached_return_t memcached_server_remove(memcached_server_st *st_ptr); LIBMEMCACHED_API memcached_server_st *memcached_server_get_last_disconnect(memcached_st *ptr); diff --git a/libmemcached/memcached_stats.c b/libmemcached/memcached_stats.c index fc528fd9..e5f9a20f 100644 --- a/libmemcached/memcached_stats.c +++ b/libmemcached/memcached_stats.c @@ -30,7 +30,7 @@ static const char *memcached_stat_keys[] = { }; -static memcached_return set_data(memcached_stat_st *memc_stat, char *key, char *value) +static memcached_return_t set_data(memcached_stat_st *memc_stat, char *key, char *value) { if (strlen(key) < 1) @@ -159,7 +159,7 @@ static memcached_return set_data(memcached_stat_st *memc_stat, char *key, char * } char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat, - const char *key, memcached_return *error) + const char *key, memcached_return_t *error) { char buffer[SMALL_STRING_LEN]; int length; @@ -224,12 +224,12 @@ char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat, return ret; } -static memcached_return binary_stats_fetch(memcached_st *ptr, - memcached_stat_st *memc_stat, - char *args, - unsigned int server_key) +static memcached_return_t binary_stats_fetch(memcached_st *ptr, + memcached_stat_st *memc_stat, + char *args, + unsigned int server_key) { - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; protocol_binary_request_stats request= {.bytes= {0}}; @@ -247,7 +247,7 @@ static memcached_return binary_stats_fetch(memcached_st *ptr, request.message.header.request.keylen= htons((uint16_t)len); request.message.header.request.bodylen= htonl((uint32_t) len); - + if ((memcached_do(&ptr->hosts[server_key], request.bytes, sizeof(request.bytes), 0) != MEMCACHED_SUCCESS) || (memcached_io_write(&ptr->hosts[server_key], args, len, 1) == -1)) @@ -269,38 +269,38 @@ static memcached_return binary_stats_fetch(memcached_st *ptr, memcached_server_response_decrement(&ptr->hosts[server_key]); do { - rc= memcached_response(&ptr->hosts[server_key], buffer, - sizeof(buffer), NULL); - if (rc == MEMCACHED_END) - break; - - unlikely (rc != MEMCACHED_SUCCESS) - { - memcached_io_reset(&ptr->hosts[server_key]); - return rc; - } - - unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY) - { - WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); - WATCHPOINT_ASSERT(0); - } + rc= memcached_response(&ptr->hosts[server_key], buffer, + sizeof(buffer), NULL); + if (rc == MEMCACHED_END) + break; + + unlikely (rc != MEMCACHED_SUCCESS) + { + memcached_io_reset(&ptr->hosts[server_key]); + return rc; + } + + unlikely((set_data(memc_stat, buffer, buffer + strlen(buffer) + 1)) == MEMCACHED_UNKNOWN_STAT_KEY) + { + WATCHPOINT_ERROR(MEMCACHED_UNKNOWN_STAT_KEY); + WATCHPOINT_ASSERT(0); + } } while (1); - + /* shit... memcached_response will decrement the counter, so I need to - ** reset it.. todo: look at this and try to find a better solution. - */ + ** reset it.. todo: look at this and try to find a better solution. + */ ptr->hosts[server_key].cursor_active= 0; return MEMCACHED_SUCCESS; } -static memcached_return ascii_stats_fetch(memcached_st *ptr, - memcached_stat_st *memc_stat, - char *args, - unsigned int server_key) +static memcached_return_t ascii_stats_fetch(memcached_st *ptr, + memcached_stat_st *memc_stat, + char *args, + unsigned int server_key) { - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; size_t send_length; @@ -316,7 +316,7 @@ static memcached_return ascii_stats_fetch(memcached_st *ptr, rc= memcached_do(&ptr->hosts[server_key], buffer, send_length, 1); if (rc != MEMCACHED_SUCCESS) - goto error; + goto error; while (1) { @@ -355,10 +355,10 @@ error: return rc; } -memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return *error) +memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error) { unsigned int x; - memcached_return rc; + memcached_return_t rc; memcached_stat_st *stats; unlikely (ptr->flags.use_udp) @@ -378,13 +378,13 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur rc= MEMCACHED_SUCCESS; for (x= 0; x < ptr->number_of_hosts; x++) { - memcached_return temp_return; - + memcached_return_t temp_return; + if (ptr->flags.binary_protocol) temp_return= binary_stats_fetch(ptr, stats + x, args, x); else temp_return= ascii_stats_fetch(ptr, stats + x, args, x); - + if (temp_return != MEMCACHED_SUCCESS) rc= MEMCACHED_SOME_ERRORS; } @@ -393,10 +393,10 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur return stats; } -memcached_return memcached_stat_servername(memcached_stat_st *memc_stat, char *args, - char *hostname, unsigned int port) +memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args, + const char *hostname, in_port_t port) { - memcached_return rc; + memcached_return_t rc; memcached_st memc; memcached_st *memc_ptr; @@ -420,7 +420,7 @@ memcached_return memcached_stat_servername(memcached_stat_st *memc_stat, char *a we will add support for "found" keys. */ char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat, - memcached_return *error) + memcached_return_t *error) { (void) memc_stat; char **list; diff --git a/libmemcached/memcached_storage.c b/libmemcached/memcached_storage.c index 4645aedb..2dbcb280 100644 --- a/libmemcached/memcached_storage.c +++ b/libmemcached/memcached_storage.c @@ -16,10 +16,10 @@ typedef enum { PREPEND_OP, APPEND_OP, CAS_OP, -} memcached_storage_action; +} memcached_storage_action_t; /* Inline this */ -static const char *storage_op_string(memcached_storage_action verb) +static inline const char *storage_op_string(memcached_storage_action_t verb) { switch (verb) { @@ -42,31 +42,31 @@ static const char *storage_op_string(memcached_storage_action verb) /* NOTREACHED */ } -static memcached_return memcached_send_binary(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char *key, - size_t key_length, - const char *value, - size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas, - memcached_storage_action verb); - -static inline memcached_return memcached_send(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas, - memcached_storage_action verb) +static memcached_return_t memcached_send_binary(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char *key, + size_t key_length, + const char *value, + size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas, + memcached_storage_action_t verb); + +static inline memcached_return_t memcached_send(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas, + memcached_storage_action_t verb) { char to_write; size_t write_length; ssize_t sent_length; - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; unsigned int server_key; @@ -75,7 +75,7 @@ static inline memcached_return memcached_send(memcached_st *ptr, rc= memcached_validate_key_length(key_length, ptr->flags.binary_protocol); unlikely (rc != MEMCACHED_SUCCESS) return rc; - + unlikely (ptr->number_of_hosts == 0) return MEMCACHED_NO_SERVERS; @@ -191,12 +191,12 @@ error: } -memcached_return memcached_set(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; LIBMEMCACHED_MEMCACHED_SET_START(); rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, @@ -205,13 +205,13 @@ memcached_return memcached_set(memcached_st *ptr, const char *key, size_t key_le return rc; } -memcached_return memcached_add(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_add(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; LIBMEMCACHED_MEMCACHED_ADD_START(); rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, @@ -220,13 +220,13 @@ memcached_return memcached_add(memcached_st *ptr, return rc; } -memcached_return memcached_replace(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_replace(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; LIBMEMCACHED_MEMCACHED_REPLACE_START(); rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, @@ -235,55 +235,55 @@ memcached_return memcached_replace(memcached_st *ptr, return rc; } -memcached_return memcached_prepend(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_prepend(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, 0, PREPEND_OP); return rc; } -memcached_return memcached_append(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_append(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, 0, APPEND_OP); return rc; } -memcached_return memcached_cas(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas) +memcached_return_t memcached_cas(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas) { - memcached_return rc; + memcached_return_t rc; rc= memcached_send(ptr, key, key_length, key, key_length, value, value_length, expiration, flags, cas, CAS_OP); return rc; } -memcached_return memcached_set_by_key(memcached_st *ptr, - const char *master_key __attribute__((unused)), - size_t master_key_length __attribute__((unused)), - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_set_by_key(memcached_st *ptr, + const char *master_key __attribute__((unused)), + size_t master_key_length __attribute__((unused)), + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; LIBMEMCACHED_MEMCACHED_SET_START(); rc= memcached_send(ptr, master_key, master_key_length, key, key_length, value, value_length, @@ -292,14 +292,14 @@ memcached_return memcached_set_by_key(memcached_st *ptr, return rc; } -memcached_return memcached_add_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_add_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; LIBMEMCACHED_MEMCACHED_ADD_START(); rc= memcached_send(ptr, master_key, master_key_length, key, key_length, value, value_length, @@ -308,14 +308,14 @@ memcached_return memcached_add_by_key(memcached_st *ptr, return rc; } -memcached_return memcached_replace_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_replace_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; LIBMEMCACHED_MEMCACHED_REPLACE_START(); rc= memcached_send(ptr, master_key, master_key_length, key, key_length, value, value_length, @@ -324,50 +324,50 @@ memcached_return memcached_replace_by_key(memcached_st *ptr, return rc; } -memcached_return memcached_prepend_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_prepend_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; rc= memcached_send(ptr, master_key, master_key_length, key, key_length, value, value_length, expiration, flags, 0, PREPEND_OP); return rc; } -memcached_return memcached_append_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags) +memcached_return_t memcached_append_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags) { - memcached_return rc; + memcached_return_t rc; rc= memcached_send(ptr, master_key, master_key_length, key, key_length, value, value_length, expiration, flags, 0, APPEND_OP); return rc; } -memcached_return memcached_cas_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas) +memcached_return_t memcached_cas_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas) { - memcached_return rc; + memcached_return_t rc; rc= memcached_send(ptr, master_key, master_key_length, key, key_length, value, value_length, expiration, flags, cas, CAS_OP); return rc; } -static inline uint8_t get_com_code(memcached_storage_action verb, bool noreply) +static inline uint8_t get_com_code(memcached_storage_action_t verb, bool noreply) { /* 0 isn't a value we want, but GCC 4.2 seems to think ret can otherwise * be used uninitialized in this function. FAIL */ @@ -420,22 +420,22 @@ static inline uint8_t get_com_code(memcached_storage_action verb, bool noreply) break; } - return ret; + return ret; } -static memcached_return memcached_send_binary(memcached_st *ptr, - const char *master_key, - size_t master_key_length, - const char *key, - size_t key_length, - const char *value, - size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas, - memcached_storage_action verb) +static memcached_return_t memcached_send_binary(memcached_st *ptr, + const char *master_key, + size_t master_key_length, + const char *key, + size_t key_length, + const char *value, + size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas, + memcached_storage_action_t verb) { uint8_t flush; protocol_binary_request_set request= {.bytes= {0}}; @@ -457,13 +457,13 @@ static memcached_return memcached_send_binary(memcached_st *ptr, request.message.body.flags= htonl(flags); request.message.body.expiration= htonl((uint32_t)expiration); } - + request.message.header.request.bodylen= htonl((uint32_t) (key_length + value_length + - request.message.header.request.extlen)); - + request.message.header.request.extlen)); + if (cas) request.message.header.request.cas= htonll(cas); - + flush= (uint8_t) ((server->root->flags.buffer_requests && verb == SET_OP) ? 0 : 1); if (server->root->flags.use_udp && !flush) @@ -475,7 +475,7 @@ static memcached_return memcached_send_binary(memcached_st *ptr, if (cmd_size + server->write_buffer_offset > MAX_UDP_DATAGRAM_LENGTH) memcached_io_write(server,NULL,0, 1); } - + /* write the header */ if ((memcached_do(server, (const char*)request.bytes, send_length, 0) != MEMCACHED_SUCCESS) || (memcached_io_write(server, key, key_length, 0) == -1) || diff --git a/libmemcached/memcached_storage.h b/libmemcached/memcached_storage.h index 834401a6..472a260a 100644 --- a/libmemcached/memcached_storage.h +++ b/libmemcached/memcached_storage.h @@ -17,88 +17,88 @@ extern "C" { /* All of the functions for adding data to the server */ LIBMEMCACHED_API -memcached_return memcached_set(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_add(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_add(memcached_st *ptr, const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_replace(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_replace(memcached_st *ptr, const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_append(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_append(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_prepend(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_prepend(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_cas(memcached_st *ptr, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas); +memcached_return_t memcached_cas(memcached_st *ptr, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas); LIBMEMCACHED_API -memcached_return memcached_set_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_set_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_add_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_add_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_replace_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_replace_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_prepend_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_prepend_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_append_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags); +memcached_return_t memcached_append_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags); LIBMEMCACHED_API -memcached_return memcached_cas_by_key(memcached_st *ptr, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - const char *value, size_t value_length, - time_t expiration, - uint32_t flags, - uint64_t cas); +memcached_return_t memcached_cas_by_key(memcached_st *ptr, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, + const char *value, size_t value_length, + time_t expiration, + uint32_t flags, + uint64_t cas); #ifdef __cplusplus } diff --git a/libmemcached/memcached_strerror.c b/libmemcached/memcached_strerror.c index 28f55a21..f1d651c9 100644 --- a/libmemcached/memcached_strerror.c +++ b/libmemcached/memcached_strerror.c @@ -1,6 +1,6 @@ #include "common.h" -const char *memcached_strerror(memcached_st *ptr __attribute__((unused)), memcached_return rc) +const char *memcached_strerror(memcached_st *ptr __attribute__((unused)), memcached_return_t rc) { switch (rc) { diff --git a/libmemcached/memcached_string.c b/libmemcached/memcached_string.c index 0911b409..a12d6d96 100644 --- a/libmemcached/memcached_string.c +++ b/libmemcached/memcached_string.c @@ -1,6 +1,15 @@ +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * + */ + #include "common.h" -inline static memcached_return _string_check(memcached_string_st *string, size_t need) +inline static memcached_return_t _string_check(memcached_string_st *string, size_t need) { if (need && need > (size_t)(string->current_size - (size_t)(string->end - string->string))) { @@ -34,7 +43,7 @@ inline static memcached_return _string_check(memcached_string_st *string, size_t memcached_string_st *memcached_string_create(memcached_st *memc, memcached_string_st *string, size_t initial_size) { - memcached_return rc; + memcached_return_t rc; /* Saving malloc calls :) */ if (string) @@ -71,10 +80,10 @@ memcached_string_st *memcached_string_create(memcached_st *memc, memcached_strin return string; } -memcached_return memcached_string_append_character(memcached_string_st *string, +memcached_return_t memcached_string_append_character(memcached_string_st *string, char character) { - memcached_return rc; + memcached_return_t rc; rc= _string_check(string, 1); @@ -87,10 +96,10 @@ memcached_return memcached_string_append_character(memcached_string_st *string, return MEMCACHED_SUCCESS; } -memcached_return memcached_string_append(memcached_string_st *string, +memcached_return_t memcached_string_append(memcached_string_st *string, const char *value, size_t length) { - memcached_return rc; + memcached_return_t rc; rc= _string_check(string, length); @@ -125,7 +134,7 @@ char *memcached_string_c_copy(memcached_string_st *string) return c_ptr; } -memcached_return memcached_string_reset(memcached_string_st *string) +memcached_return_t memcached_string_reset(memcached_string_st *string) { string->end= string->string; @@ -153,7 +162,7 @@ void memcached_string_free(memcached_string_st *ptr) } } -memcached_return memcached_string_check(memcached_string_st *string, size_t need) +memcached_return_t memcached_string_check(memcached_string_st *string, size_t need) { return _string_check(string, need); } diff --git a/libmemcached/memcached_string.h b/libmemcached/memcached_string.h index 6ecdbe94..d93bc0d2 100644 --- a/libmemcached/memcached_string.h +++ b/libmemcached/memcached_string.h @@ -1,9 +1,12 @@ -/* - * Summary: String structure used for libmemcached. +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. + * + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. * - * Copy: See Copyright for the status of this software. + * Summary: String structure used for libmemcached. * - * Author: Brian Aker */ #ifndef __MEMCACHED_STRING_H__ @@ -35,19 +38,19 @@ memcached_string_st *memcached_string_create(memcached_st *ptr, memcached_string_st *string, size_t initial_size); LIBMEMCACHED_API -memcached_return memcached_string_check(memcached_string_st *string, size_t need); +memcached_return_t memcached_string_check(memcached_string_st *string, size_t need); LIBMEMCACHED_API char *memcached_string_c_copy(memcached_string_st *string); LIBMEMCACHED_API -memcached_return memcached_string_append_character(memcached_string_st *string, - char character); +memcached_return_t memcached_string_append_character(memcached_string_st *string, + char character); LIBMEMCACHED_API -memcached_return memcached_string_append(memcached_string_st *string, - const char *value, size_t length); +memcached_return_t memcached_string_append(memcached_string_st *string, + const char *value, size_t length); LIBMEMCACHED_API -memcached_return memcached_string_reset(memcached_string_st *string); +memcached_return_t memcached_string_reset(memcached_string_st *string); LIBMEMCACHED_API void memcached_string_free(memcached_string_st *string); diff --git a/libmemcached/memcached_types.h b/libmemcached/memcached_types.h index 9d2537d4..58f0887a 100644 --- a/libmemcached/memcached_types.h +++ b/libmemcached/memcached_types.h @@ -1,9 +1,12 @@ -/* - * Summary: Typpes for libmemcached +/* LibMemcached + * Copyright (C) 2006-2009 Brian Aker + * All rights reserved. * - * Copy: See Copyright for the status of this software. + * Use and distribution licensed under the BSD license. See + * the COPYING file in the parent directory for full text. + * + * Summary: Types for libmemcached * - * Author: Brian Aker */ #ifndef LIBMEMCACHED_MEMCACHED_TYPES_H @@ -20,29 +23,52 @@ typedef struct memcached_result_st memcached_result_st; typedef struct memcached_string_st memcached_string_st; typedef struct memcached_server_st memcached_server_st; typedef struct memcached_continuum_item_st memcached_continuum_item_st; -typedef memcached_return (*memcached_clone_func)(memcached_st *parent, memcached_st *clone); -typedef memcached_return (*memcached_cleanup_func)(memcached_st *ptr); -typedef void (*memcached_free_function)(memcached_st *ptr, void *mem); -typedef void *(*memcached_malloc_function)(memcached_st *ptr, const size_t size); -typedef void *(*memcached_realloc_function)(memcached_st *ptr, void *mem, const size_t size); -typedef void *(*memcached_calloc_function)(memcached_st *ptr, size_t nelem, const size_t elsize); -typedef memcached_return (*memcached_execute_function)(memcached_st *ptr, memcached_result_st *result, void *context); -typedef memcached_return (*memcached_server_function)(memcached_st *ptr, memcached_server_st *server, void *context); -typedef memcached_return (*memcached_trigger_key)(memcached_st *ptr, - const char *key, size_t key_length, - memcached_result_st *result); -typedef memcached_return (*memcached_trigger_delete_key)(memcached_st *ptr, - const char *key, size_t key_length); - -typedef memcached_return (*memcached_dump_func)(memcached_st *ptr, - const char *key, size_t key_length, void *context); +typedef memcached_return_t (*memcached_clone_fn)(memcached_st *parent, memcached_st *clone); +typedef memcached_return_t (*memcached_cleanup_fn)(memcached_st *ptr); +typedef void (*memcached_free_fn)(memcached_st *ptr, void *mem); +typedef void *(*memcached_malloc_fn)(memcached_st *ptr, const size_t size); +typedef void *(*memcached_realloc_fn)(memcached_st *ptr, void *mem, const size_t size); +typedef void *(*memcached_calloc_fn)(memcached_st *ptr, size_t nelem, const size_t elsize); +typedef memcached_return_t (*memcached_execute_fn)(memcached_st *ptr, memcached_result_st *result, void *context); +typedef memcached_return_t (*memcached_server_fn)(memcached_st *ptr, memcached_server_st *server, void *context); +typedef memcached_return_t (*memcached_trigger_key_fn)(memcached_st *ptr, + const char *key, size_t key_length, + memcached_result_st *result); +typedef memcached_return_t (*memcached_trigger_delete_key_fn)(memcached_st *ptr, + const char *key, size_t key_length); + +typedef memcached_return_t (*memcached_dump_fn)(memcached_st *ptr, + const char *key, size_t key_length, void *context); typedef struct { - memcached_execute_function *callback; + memcached_execute_fn *callback; void *context; - unsigned int number_of_callback; + uint32_t number_of_callback; } memcached_callback_st; + +/** + @note The following definitions are just here for backwards compatibility. +*/ +typedef memcached_return_t memcached_return; +typedef memcached_server_distribution_t memcached_server_distribution; +typedef memcached_behavior_t memcached_behavior; +typedef memcached_callback_t memcached_callback; +typedef memcached_hash_t memcached_hash; +typedef memcached_connection_t memcached_connection; +typedef memcached_clone_fn memcached_clone_func; +typedef memcached_cleanup_fn memcached_cleanup_func; +typedef memcached_free_fn memcached_free_function; +typedef memcached_malloc_fn memcached_malloc_function; +typedef memcached_realloc_fn memcached_realloc_function; +typedef memcached_calloc_fn memcached_calloc_function; +typedef memcached_execute_fn memcached_execute_function; +typedef memcached_server_fn memcached_server_function; +typedef memcached_trigger_key_fn memcached_trigger_key; +typedef memcached_trigger_delete_key_fn memcached_trigger_delete_key; +typedef memcached_dump_fn memcached_dump_func; + + #ifdef __cplusplus } #endif diff --git a/libmemcached/memcached_verbosity.c b/libmemcached/memcached_verbosity.c index f9bd928a..3d34880d 100644 --- a/libmemcached/memcached_verbosity.c +++ b/libmemcached/memcached_verbosity.c @@ -1,10 +1,10 @@ #include "common.h" -memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity) +memcached_return_t memcached_verbosity(memcached_st *ptr, unsigned int verbosity) { unsigned int x; size_t send_length; - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; send_length= (size_t) snprintf(buffer, MEMCACHED_DEFAULT_COMMAND_SIZE, @@ -15,7 +15,7 @@ memcached_return memcached_verbosity(memcached_st *ptr, unsigned int verbosity) rc= MEMCACHED_SUCCESS; for (x= 0; x < ptr->number_of_hosts; x++) { - memcached_return rrc; + memcached_return_t rrc; rrc= memcached_do(&ptr->hosts[x], buffer, send_length, 1); if (rrc != MEMCACHED_SUCCESS) diff --git a/libmemcached/memcached_version.c b/libmemcached/memcached_version.c index 932e39f1..db2419cf 100644 --- a/libmemcached/memcached_version.c +++ b/libmemcached/memcached_version.c @@ -5,25 +5,25 @@ const char * memcached_lib_version(void) return LIBMEMCACHED_VERSION_STRING; } -static inline memcached_return memcached_version_binary(memcached_st *ptr); -static inline memcached_return memcached_version_textual(memcached_st *ptr); +static inline memcached_return_t memcached_version_binary(memcached_st *ptr); +static inline memcached_return_t memcached_version_textual(memcached_st *ptr); -memcached_return memcached_version(memcached_st *ptr) +memcached_return_t memcached_version(memcached_st *ptr) { - if (ptr->flags.use_udp) + if (ptr->flags.use_udp) return MEMCACHED_NOT_SUPPORTED; - if (ptr->flags.binary_protocol) - return memcached_version_binary(ptr); - else - return memcached_version_textual(ptr); + if (ptr->flags.binary_protocol) + return memcached_version_binary(ptr); + else + return memcached_version_textual(ptr); } -static inline memcached_return memcached_version_textual(memcached_st *ptr) +static inline memcached_return_t memcached_version_textual(memcached_st *ptr) { unsigned int x; size_t send_length; - memcached_return rc; + memcached_return_t rc; char buffer[MEMCACHED_DEFAULT_COMMAND_SIZE]; char *response_ptr; const char *command= "version\r\n"; @@ -33,7 +33,7 @@ static inline memcached_return memcached_version_textual(memcached_st *ptr) rc= MEMCACHED_SUCCESS; for (x= 0; x < ptr->number_of_hosts; x++) { - memcached_return rrc; + memcached_return_t rrc; rrc= memcached_do(&ptr->hosts[x], command, send_length, 1); if (rrc != MEMCACHED_SUCCESS) @@ -65,9 +65,9 @@ static inline memcached_return memcached_version_textual(memcached_st *ptr) return rc; } -static inline memcached_return memcached_version_binary(memcached_st *ptr) +static inline memcached_return_t memcached_version_binary(memcached_st *ptr) { - memcached_return rc; + memcached_return_t rc; unsigned int x; protocol_binary_request_version request= { .bytes= {0}}; request.message.header.request.magic= PROTOCOL_BINARY_REQ; @@ -77,7 +77,7 @@ static inline memcached_return memcached_version_binary(memcached_st *ptr) rc= MEMCACHED_SUCCESS; for (x= 0; x < ptr->number_of_hosts; x++) { - memcached_return rrc; + memcached_return_t rrc; rrc= memcached_do(&ptr->hosts[x], request.bytes, sizeof(request.bytes), 1); if (rrc != MEMCACHED_SUCCESS) @@ -91,7 +91,7 @@ static inline memcached_return memcached_version_binary(memcached_st *ptr) for (x= 0; x < ptr->number_of_hosts; x++) if (memcached_server_response_count(&ptr->hosts[x]) > 0) { - memcached_return rrc; + memcached_return_t rrc; char buffer[32]; char *p; diff --git a/libmemcached/util/memcached_pool.c b/libmemcached/util/memcached_pool.c index afc2fee3..fac7d2d3 100644 --- a/libmemcached/util/memcached_pool.c +++ b/libmemcached/util/memcached_pool.c @@ -14,10 +14,10 @@ struct memcached_pool_st int firstfree; uint32_t size; uint32_t current_size; - char* version; + char *version; }; -static memcached_return mutex_enter(pthread_mutex_t *mutex) +static memcached_return_t mutex_enter(pthread_mutex_t *mutex) { int ret; do @@ -27,7 +27,7 @@ static memcached_return mutex_enter(pthread_mutex_t *mutex) return (ret == -1) ? MEMCACHED_ERRNO : MEMCACHED_SUCCESS; } -static memcached_return mutex_exit(pthread_mutex_t *mutex) { +static memcached_return_t mutex_exit(pthread_mutex_t *mutex) { int ret; do ret= pthread_mutex_unlock(mutex); @@ -62,12 +62,12 @@ memcached_pool_st *memcached_pool_create(memcached_st* mmc, { memcached_pool_st* ret = NULL; memcached_pool_st object = { .mutex = PTHREAD_MUTEX_INITIALIZER, - .cond = PTHREAD_COND_INITIALIZER, - .master = mmc, - .mmc = calloc(max, sizeof(memcached_st*)), - .firstfree = -1, - .size = max, - .current_size = 0 }; + .cond = PTHREAD_COND_INITIALIZER, + .master = mmc, + .mmc = calloc(max, sizeof(memcached_st*)), + .firstfree = -1, + .size = max, + .current_size = 0 }; if (object.mmc != NULL) { @@ -82,7 +82,7 @@ memcached_pool_st *memcached_pool_create(memcached_st* mmc, /* Try to create the initial size of the pool. An allocation failure at * this time is not fatal.. - */ + */ for (unsigned int ii=0; ii < initial; ++ii) if (grow_pool(ret) == -1) break; @@ -101,7 +101,7 @@ memcached_st* memcached_pool_destroy(memcached_pool_st* pool) free(pool->mmc[xx]); pool->mmc[xx] = NULL; } - + pthread_mutex_destroy(&pool->mutex); pthread_cond_destroy(&pool->cond); free(pool->mmc); @@ -112,7 +112,7 @@ memcached_st* memcached_pool_destroy(memcached_pool_st* pool) memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, - memcached_return *rc) + memcached_return_t *rc) { memcached_st *ret= NULL; if ((*rc= mutex_enter(&pool->mutex)) != MEMCACHED_SUCCESS) @@ -121,7 +121,7 @@ memcached_st* memcached_pool_pop(memcached_pool_st* pool, do { if (pool->firstfree > -1) - ret= pool->mmc[pool->firstfree--]; + ret= pool->mmc[pool->firstfree--]; else if (pool->current_size == pool->size) { if (!block) @@ -141,8 +141,8 @@ memcached_st* memcached_pool_pop(memcached_pool_st* pool, } else if (grow_pool(pool) == -1) { - *rc= mutex_exit(&pool->mutex); - return NULL; + *rc= mutex_exit(&pool->mutex); + return NULL; } } while (ret == NULL); @@ -152,10 +152,10 @@ memcached_st* memcached_pool_pop(memcached_pool_st* pool, return ret; } -memcached_return memcached_pool_push(memcached_pool_st* pool, - memcached_st *mmc) +memcached_return_t memcached_pool_push(memcached_pool_st* pool, + memcached_st *mmc) { - memcached_return rc= mutex_enter(&pool->mutex); + memcached_return_t rc= mutex_enter(&pool->mutex); if (rc != MEMCACHED_SUCCESS) return rc; @@ -180,7 +180,7 @@ memcached_return memcached_pool_push(memcached_pool_st* pool, pthread_cond_broadcast(&pool->cond); } - memcached_return rval= mutex_exit(&pool->mutex); + memcached_return_t rval= mutex_exit(&pool->mutex); if (rc == MEMCACHED_SOME_ERRORS) return rc; @@ -188,14 +188,14 @@ memcached_return memcached_pool_push(memcached_pool_st* pool, } -memcached_return memcached_pool_behavior_set(memcached_pool_st *pool, - memcached_behavior flag, - uint64_t data) +memcached_return_t memcached_pool_behavior_set(memcached_pool_st *pool, + memcached_behavior_t flag, + uint64_t data) { - memcached_return rc= mutex_enter(&pool->mutex); + memcached_return_t rc= mutex_enter(&pool->mutex); if (rc != MEMCACHED_SUCCESS) - return rc; + return rc; /* update the master */ rc= memcached_behavior_set(pool->master, flag, data); @@ -220,10 +220,10 @@ memcached_return memcached_pool_behavior_set(memcached_pool_st *pool, if (memcached_clone(pool->mmc[xx], pool->master) == NULL) { /* I'm not sure what to do in this case.. this would happen - if we fail to push the server list inside the client.. - I should add a testcase for this, but I believe the following - would work, except that you would add a hole in the pool list.. - in theory you could end up with an empty pool.... + if we fail to push the server list inside the client.. + I should add a testcase for this, but I believe the following + would work, except that you would add a hole in the pool list.. + in theory you could end up with an empty pool.... */ free(pool->mmc[xx]); pool->mmc[xx]= NULL; @@ -234,11 +234,11 @@ memcached_return memcached_pool_behavior_set(memcached_pool_st *pool, return mutex_exit(&pool->mutex); } -memcached_return memcached_pool_behavior_get(memcached_pool_st *pool, - memcached_behavior flag, - uint64_t *value) +memcached_return_t memcached_pool_behavior_get(memcached_pool_st *pool, + memcached_behavior_t flag, + uint64_t *value) { - memcached_return rc= mutex_enter(&pool->mutex); + memcached_return_t rc= mutex_enter(&pool->mutex); if (rc != MEMCACHED_SUCCESS) return rc; *value= memcached_behavior_get(pool->master, flag); diff --git a/tests/atomsmasher.c b/tests/atomsmasher.c index ca62f322..7650f592 100644 --- a/tests/atomsmasher.c +++ b/tests/atomsmasher.c @@ -62,7 +62,7 @@ static test_return_t generate_pairs(memcached_st *memc __attribute__((unused))) static test_return_t drizzle(memcached_st *memc) { unsigned int x; - memcached_return rc; + memcached_return_t rc; char *return_value; size_t return_value_length; uint32_t flags; @@ -111,38 +111,38 @@ infinite: return 0; } -static memcached_return pre_nonblock(memcached_st *memc) +static memcached_return_t pre_nonblock(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); return MEMCACHED_SUCCESS; } -static memcached_return pre_md5(memcached_st *memc) +static memcached_return_t pre_md5(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5); return MEMCACHED_SUCCESS; } -static memcached_return pre_hsieh(memcached_st *memc) +static memcached_return_t pre_hsieh(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH); return MEMCACHED_SUCCESS; } -static memcached_return enable_consistent(memcached_st *memc) +static memcached_return_t enable_consistent(memcached_st *memc) { - memcached_server_distribution value= MEMCACHED_DISTRIBUTION_CONSISTENT; - memcached_hash hash; + memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT; + memcached_hash_t hash; memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value); pre_hsieh(memc); - value= (memcached_server_distribution)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION); + value= (memcached_server_distribution_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION); assert(value == MEMCACHED_DISTRIBUTION_CONSISTENT); - hash= (memcached_hash)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH); + hash= (memcached_hash_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH); assert(hash == MEMCACHED_HASH_HSIEH); @@ -155,7 +155,7 @@ static memcached_return enable_consistent(memcached_st *memc) */ static test_return_t add_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; unsigned long long setting_value; diff --git a/tests/function.c b/tests/function.c index a882ae8c..6549f582 100644 --- a/tests/function.c +++ b/tests/function.c @@ -55,7 +55,7 @@ static test_return_t init_test(memcached_st *not_used __attribute__((unused))) static test_return_t server_list_null_test(memcached_st *ptr __attribute__((unused))) { memcached_server_st *server_list; - memcached_return rc; + memcached_return_t rc; server_list= memcached_server_list_append_with_weight(NULL, NULL, 0, 0, NULL); test_truth(server_list == NULL); @@ -72,7 +72,7 @@ static test_return_t server_list_null_test(memcached_st *ptr __attribute__((unu #define TEST_PORT_COUNT 7 uint32_t test_ports[TEST_PORT_COUNT]; -static memcached_return server_display_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context) +static memcached_return_t server_display_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context) { /* Do Nothing */ uint32_t bigger= *((uint32_t *)(context)); @@ -86,8 +86,8 @@ static test_return_t server_sort_test(memcached_st *ptr __attribute__((unused)) { uint32_t x; uint32_t bigger= 0; /* Prime the value for the test_truth in server_display_function */ - memcached_return rc; - memcached_server_function callbacks[1]; + memcached_return_t rc; + memcached_server_fn callbacks[1]; memcached_st *local_memc; local_memc= memcached_create(NULL); @@ -115,8 +115,8 @@ static test_return_t server_sort_test(memcached_st *ptr __attribute__((unused)) static test_return_t server_sort2_test(memcached_st *ptr __attribute__((unused))) { uint32_t bigger= 0; /* Prime the value for the test_truth in server_display_function */ - memcached_return rc; - memcached_server_function callbacks[1]; + memcached_return_t rc; + memcached_server_fn callbacks[1]; memcached_st *local_memc; local_memc= memcached_create(NULL); @@ -142,7 +142,7 @@ static test_return_t server_sort2_test(memcached_st *ptr __attribute__((unused) return TEST_SUCCESS; } -static memcached_return server_display_unsort_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context) +static memcached_return_t server_display_unsort_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server, void *context) { /* Do Nothing */ uint32_t x= *((uint32_t *)(context)); @@ -158,8 +158,8 @@ static test_return_t server_unsort_test(memcached_st *ptr __attribute__((unused uint32_t x; uint32_t counter= 0; /* Prime the value for the test_truth in server_display_function */ uint32_t bigger= 0; /* Prime the value for the test_truth in server_display_function */ - memcached_return rc; - memcached_server_function callbacks[1]; + memcached_return_t rc; + memcached_server_fn callbacks[1]; memcached_st *local_memc; local_memc= memcached_create(NULL); @@ -295,7 +295,7 @@ static test_return_t userdata_test(memcached_st *memc) static test_return_t connection_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; rc= memcached_server_add_with_weight(memc, "localhost", 0, 0); test_truth(rc == MEMCACHED_SUCCESS); @@ -305,7 +305,7 @@ static test_return_t connection_test(memcached_st *memc) static test_return_t error_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; uint32_t values[] = { 851992627U, 2337886783U, 3196981036U, 4001849190U, 982370485U, 1263635348U, 4242906218U, 3829656100U, 1891735253U, 334139633U, 2257084983U, 3088286104U, @@ -333,7 +333,7 @@ static test_return_t error_test(memcached_st *memc) static test_return_t set_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; @@ -347,7 +347,7 @@ static test_return_t set_test(memcached_st *memc) static test_return_t append_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "fig"; const char *in_value= "we"; char *out_value= NULL; @@ -384,7 +384,7 @@ static test_return_t append_test(memcached_st *memc) static test_return_t append_binary_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "numbers"; unsigned int *store_ptr; unsigned int store_list[] = { 23, 56, 499, 98, 32847, 0 }; @@ -430,7 +430,7 @@ static test_return_t append_binary_test(memcached_st *memc) static test_return_t cas2_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; const char *value= "we the people"; @@ -474,7 +474,7 @@ static test_return_t cas2_test(memcached_st *memc) static test_return_t cas_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "fun"; size_t key_length= strlen(key); const char *value= "we the people"; @@ -534,7 +534,7 @@ static test_return_t cas_test(memcached_st *memc) static test_return_t prepend_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "fig"; const char *value= "people"; char *out_value= NULL; @@ -575,7 +575,7 @@ static test_return_t prepend_test(memcached_st *memc) */ static test_return_t add_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; unsigned long long setting_value; @@ -630,7 +630,7 @@ static test_return_t add_wrapper(memcached_st *memc) static test_return_t replace_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; const char *original= "first we insert some data"; @@ -650,7 +650,7 @@ static test_return_t replace_test(memcached_st *memc) static test_return_t delete_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; @@ -667,7 +667,7 @@ static test_return_t delete_test(memcached_st *memc) static test_return_t flush_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; rc= memcached_flush(memc, 0); test_truth(rc == MEMCACHED_SUCCESS); @@ -675,7 +675,7 @@ static test_return_t flush_test(memcached_st *memc) return TEST_SUCCESS; } -static memcached_return server_function(memcached_st *ptr __attribute__((unused)), +static memcached_return_t server_function(memcached_st *ptr __attribute__((unused)), memcached_server_st *server __attribute__((unused)), void *context __attribute__((unused))) { @@ -688,7 +688,7 @@ static test_return_t memcached_server_cursor_test(memcached_st *memc) { char context[8]; strcpy(context, "foo bad"); - memcached_server_function callbacks[1]; + memcached_server_fn callbacks[1]; callbacks[0]= server_function; memcached_server_cursor(memc, callbacks, context, 1); @@ -697,7 +697,7 @@ static test_return_t memcached_server_cursor_test(memcached_st *memc) static test_return_t bad_key_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo bad"; char *string; size_t string_length; @@ -788,7 +788,7 @@ static test_return_t bad_key_test(memcached_st *memc) } #define READ_THROUGH_VALUE "set for me" -static memcached_return read_through_trigger(memcached_st *memc __attribute__((unused)), +static memcached_return_t read_through_trigger(memcached_st *memc __attribute__((unused)), char *key __attribute__((unused)), size_t key_length __attribute__((unused)), memcached_result_st *result) @@ -799,12 +799,12 @@ static memcached_return read_through_trigger(memcached_st *memc __attribute__(( static test_return_t read_through(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; char *string; size_t string_length; uint32_t flags; - memcached_trigger_key cb= (memcached_trigger_key)read_through_trigger; + memcached_trigger_key_fn cb= (memcached_trigger_key_fn)read_through_trigger; string= memcached_get(memc, key, strlen(key), &string_length, &flags, &rc); @@ -836,7 +836,7 @@ static test_return_t read_through(memcached_st *memc) return TEST_SUCCESS; } -static memcached_return delete_trigger(memcached_st *ptr __attribute__((unused)), +static memcached_return_t delete_trigger(memcached_st *ptr __attribute__((unused)), const char *key, size_t key_length __attribute__((unused))) { @@ -847,10 +847,10 @@ static memcached_return delete_trigger(memcached_st *ptr __attribute__((unused) static test_return_t delete_through(memcached_st *memc) { - memcached_trigger_delete_key callback; - memcached_return rc; + memcached_trigger_delete_key_fn callback; + memcached_return_t rc; - callback= (memcached_trigger_delete_key)delete_trigger; + callback= (memcached_trigger_delete_key_fn)delete_trigger; rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_DELETE_TRIGGER, *(void**)&callback); test_truth(rc == MEMCACHED_SUCCESS); @@ -860,7 +860,7 @@ static test_return_t delete_through(memcached_st *memc) static test_return_t get_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; char *string; size_t string_length; @@ -881,7 +881,7 @@ static test_return_t get_test(memcached_st *memc) static test_return_t get_test2(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; char *string; @@ -908,7 +908,7 @@ static test_return_t get_test2(memcached_st *memc) static test_return_t set_test2(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "train in the brain"; size_t value_length= strlen(value); @@ -927,7 +927,7 @@ static test_return_t set_test2(memcached_st *memc) static test_return_t set_test3(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; char *value; size_t value_length= 8191; unsigned int x; @@ -958,7 +958,7 @@ static test_return_t set_test3(memcached_st *memc) static test_return_t get_test3(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; char *value; size_t value_length= 8191; @@ -994,7 +994,7 @@ static test_return_t get_test3(memcached_st *memc) static test_return_t get_test4(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; char *value; size_t value_length= 8191; @@ -1047,7 +1047,7 @@ static test_return_t get_test5(memcached_st *memc) uint32_t flags; size_t rlen; - memcached_return rc= memcached_set(memc, keys[0], lengths[0], + memcached_return_t rc= memcached_set(memc, keys[0], lengths[0], keys[0], lengths[0], 0, 0); test_truth(rc == MEMCACHED_SUCCESS); rc= memcached_mget(memc, keys, lengths, 2); @@ -1082,7 +1082,7 @@ static test_return_t mget_end(memcached_st *memc) size_t lengths[]= { 3, 4 }; const char *values[]= { "fjord", "41" }; - memcached_return rc; + memcached_return_t rc; // Set foo and foo2 for (int i= 0; i < 2; i++) @@ -1143,7 +1143,7 @@ static test_return_t mget_end(memcached_st *memc) /* Do not copy the style of this code, I just access hosts to testthis function */ static test_return_t stats_servername_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; memcached_stat_st memc_stat; rc= memcached_stat_servername(&memc_stat, NULL, memc->hosts[0].hostname, @@ -1155,7 +1155,7 @@ static test_return_t stats_servername_test(memcached_st *memc) static test_return_t increment_test(memcached_st *memc) { uint64_t new_number; - memcached_return rc; + memcached_return_t rc; const char *key= "number"; const char *value= "0"; @@ -1182,7 +1182,7 @@ static test_return_t increment_with_initial_test(memcached_st *memc) if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0) { uint64_t new_number; - memcached_return rc; + memcached_return_t rc; const char *key= "number"; uint64_t initial= 0; @@ -1202,7 +1202,7 @@ static test_return_t increment_with_initial_test(memcached_st *memc) static test_return_t decrement_test(memcached_st *memc) { uint64_t new_number; - memcached_return rc; + memcached_return_t rc; const char *key= "number"; const char *value= "3"; @@ -1229,7 +1229,7 @@ static test_return_t decrement_with_initial_test(memcached_st *memc) if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0) { uint64_t new_number; - memcached_return rc; + memcached_return_t rc; const char *key= "number"; uint64_t initial= 3; @@ -1249,7 +1249,7 @@ static test_return_t decrement_with_initial_test(memcached_st *memc) static test_return_t increment_by_key_test(memcached_st *memc) { uint64_t new_number; - memcached_return rc; + memcached_return_t rc; const char *master_key= "foo"; const char *key= "number"; const char *value= "0"; @@ -1278,7 +1278,7 @@ static test_return_t increment_with_initial_by_key_test(memcached_st *memc) if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0) { uint64_t new_number; - memcached_return rc; + memcached_return_t rc; const char *master_key= "foo"; const char *key= "number"; uint64_t initial= 0; @@ -1301,7 +1301,7 @@ static test_return_t increment_with_initial_by_key_test(memcached_st *memc) static test_return_t decrement_by_key_test(memcached_st *memc) { uint64_t new_number; - memcached_return rc; + memcached_return_t rc; const char *master_key= "foo"; const char *key= "number"; const char *value= "3"; @@ -1332,7 +1332,7 @@ static test_return_t decrement_with_initial_by_key_test(memcached_st *memc) if (memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_BINARY_PROTOCOL) != 0) { uint64_t new_number; - memcached_return rc; + memcached_return_t rc; const char *master_key= "foo"; const char *key= "number"; uint64_t initial= 3; @@ -1354,7 +1354,7 @@ static test_return_t decrement_with_initial_by_key_test(memcached_st *memc) static test_return_t quit_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "fudge"; const char *value= "sanford and sun"; @@ -1374,7 +1374,7 @@ static test_return_t quit_test(memcached_st *memc) static test_return_t mget_result_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; unsigned int x; @@ -1431,7 +1431,7 @@ static test_return_t mget_result_test(memcached_st *memc) static test_return_t mget_result_alloc_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; unsigned int x; @@ -1480,7 +1480,7 @@ static test_return_t mget_result_alloc_test(memcached_st *memc) } /* Count the results */ -static memcached_return callback_counter(memcached_st *ptr __attribute__((unused)), +static memcached_return_t callback_counter(memcached_st *ptr __attribute__((unused)), memcached_result_st *result __attribute__((unused)), void *context) { @@ -1493,12 +1493,12 @@ static memcached_return callback_counter(memcached_st *ptr __attribute__((unused static test_return_t mget_result_function(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; unsigned int x; unsigned int counter; - memcached_execute_function callbacks[1]; + memcached_execute_fn callbacks[1]; /* We need to empty the server before continueing test */ rc= memcached_flush(memc, 0); @@ -1524,7 +1524,7 @@ static test_return_t mget_result_function(memcached_st *memc) static test_return_t mget_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; unsigned int x; @@ -1598,7 +1598,7 @@ static test_return_t mget_execute(memcached_st *memc) /* First add all of the items.. */ char blob[1024] = {0}; - memcached_return rc; + memcached_return_t rc; for (int x= 0; x < max_keys; ++x) { char k[251]; @@ -1611,7 +1611,7 @@ static test_return_t mget_execute(memcached_st *memc) /* Try to get all of them with a large multiget */ unsigned int counter= 0; - memcached_execute_function callbacks[1]= { [0]= &callback_counter }; + memcached_execute_fn callbacks[1]= { [0]= &callback_counter }; rc= memcached_mget_execute(memc, (const char**)keys, key_length, (size_t)max_keys, callbacks, &counter, 1); @@ -1646,7 +1646,7 @@ static test_return_t get_stats_keys(memcached_st *memc) char **list; char **ptr; memcached_stat_st memc_stat; - memcached_return rc; + memcached_return_t rc; list= memcached_stat_get_keys(memc, &memc_stat, &rc); test_truth(rc == MEMCACHED_SUCCESS); @@ -1675,7 +1675,7 @@ static test_return_t get_stats(memcached_st *memc) unsigned int x; char **list; char **ptr; - memcached_return rc; + memcached_return_t rc; memcached_stat_st *memc_stat; memc_stat= memcached_stat(memc, NULL, &rc); @@ -1702,7 +1702,7 @@ static test_return_t add_host_test(memcached_st *memc) { unsigned int x; memcached_server_st *servers; - memcached_return rc; + memcached_return_t rc; char servername[]= "0.example.com"; servers= memcached_server_list_append_with_weight(NULL, servername, 400, 0, &rc); @@ -1730,12 +1730,12 @@ static test_return_t add_host_test(memcached_st *memc) return TEST_SUCCESS; } -static memcached_return clone_test_callback(memcached_st *parent __attribute__((unused)), memcached_st *memc_clone __attribute__((unused))) +static memcached_return_t clone_test_callback(memcached_st *parent __attribute__((unused)), memcached_st *memc_clone __attribute__((unused))) { return MEMCACHED_SUCCESS; } -static memcached_return cleanup_test_callback(memcached_st *ptr __attribute__((unused))) +static memcached_return_t cleanup_test_callback(memcached_st *ptr __attribute__((unused))) { return MEMCACHED_SUCCESS; } @@ -1746,7 +1746,7 @@ static test_return_t callback_test(memcached_st *memc) { int x= 5; int *test_ptr; - memcached_return rc; + memcached_return_t rc; rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_USER_DATA, &x); test_truth(rc == MEMCACHED_SUCCESS); @@ -1756,10 +1756,10 @@ static test_return_t callback_test(memcached_st *memc) /* Test Clone Callback */ { - memcached_clone_func clone_cb= (memcached_clone_func)clone_test_callback; + memcached_clone_fn clone_cb= (memcached_clone_fn)clone_test_callback; void *clone_cb_ptr= *(void **)&clone_cb; void *temp_function= NULL; - memcached_return rc; + memcached_return_t rc; rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, clone_cb_ptr); @@ -1770,11 +1770,11 @@ static test_return_t callback_test(memcached_st *memc) /* Test Cleanup Callback */ { - memcached_cleanup_func cleanup_cb= - (memcached_cleanup_func)cleanup_test_callback; + memcached_cleanup_fn cleanup_cb= + (memcached_cleanup_fn)cleanup_test_callback; void *cleanup_cb_ptr= *(void **)&cleanup_cb; void *temp_function= NULL; - memcached_return rc; + memcached_return_t rc; rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_CLONE_FUNCTION, cleanup_cb_ptr); @@ -1839,7 +1839,7 @@ static test_return_t behavior_test(memcached_st *memc) static test_return_t fetch_all_results(memcached_st *memc) { - memcached_return rc= MEMCACHED_SUCCESS; + memcached_return_t rc= MEMCACHED_SUCCESS; char return_key[MEMCACHED_MAX_KEY]; size_t return_key_length; char *return_value; @@ -1867,7 +1867,7 @@ static test_return_t user_supplied_bug1(memcached_st *memc) uint32_t size= 0; char key[10]; char randomstuff[6 * 1024]; - memcached_return rc; + memcached_return_t rc; memset(randomstuff, 0, 6 * 1024); @@ -1929,7 +1929,7 @@ static test_return_t user_supplied_bug2(memcached_st *memc) for (x= 0, errors= 0, total= 0 ; total < 24576 ; x++) { - memcached_return rc= MEMCACHED_SUCCESS; + memcached_return_t rc= MEMCACHED_SUCCESS; char buffer[SMALL_STRING_LEN]; uint32_t flags= 0; size_t val_len= 0; @@ -1963,7 +1963,7 @@ static test_return_t user_supplied_bug2(memcached_st *memc) #define KEY_COUNT 3000 // * 1024576 static test_return_t user_supplied_bug3(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; unsigned int setter; unsigned int x; char **keys; @@ -2007,7 +2007,7 @@ static test_return_t user_supplied_bug3(memcached_st *memc) /* Make sure we behave properly if server list has no values */ static test_return_t user_supplied_bug4(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"fudge", "son", "food"}; size_t key_length[]= {5, 3, 4}; unsigned int x; @@ -2070,7 +2070,7 @@ static test_return_t user_supplied_bug4(memcached_st *memc) #define VALUE_SIZE_BUG5 1048064 static test_return_t user_supplied_bug5(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"}; size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")}; char return_key[MEMCACHED_MAX_KEY]; @@ -2128,7 +2128,7 @@ static test_return_t user_supplied_bug5(memcached_st *memc) static test_return_t user_supplied_bug6(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"036790384900", "036790384902", "036790384904", "036790384906"}; size_t key_length[]= {strlen("036790384900"), strlen("036790384902"), strlen("036790384904"), strlen("036790384906")}; char return_key[MEMCACHED_MAX_KEY]; @@ -2193,7 +2193,7 @@ static test_return_t user_supplied_bug6(memcached_st *memc) static test_return_t user_supplied_bug8(memcached_st *memc __attribute__((unused))) { - memcached_return rc; + memcached_return_t rc; memcached_st *mine; memcached_st *memc_clone; @@ -2224,7 +2224,7 @@ static test_return_t user_supplied_bug8(memcached_st *memc __attribute__((unuse /* Test flag store/retrieve */ static test_return_t user_supplied_bug7(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys= "036790384900"; size_t key_length= strlen(keys); char return_key[MEMCACHED_MAX_KEY]; @@ -2268,7 +2268,7 @@ static test_return_t user_supplied_bug7(memcached_st *memc) static test_return_t user_supplied_bug9(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *keys[]= {"UDATA:edevil@sapo.pt", "fudge&*@#", "for^#@&$not"}; size_t key_length[3]; unsigned int x; @@ -2318,7 +2318,7 @@ static test_return_t user_supplied_bug10(memcached_st *memc) size_t value_length= 512; unsigned int x; size_t key_len= 3; - memcached_return rc; + memcached_return_t rc; unsigned int set= 1; memcached_st *mclone= memcached_clone(NULL, memc); int32_t timeout; @@ -2361,7 +2361,7 @@ static test_return_t user_supplied_bug11(memcached_st *memc) size_t value_length= 512; unsigned int x; size_t key_len= 3; - memcached_return rc; + memcached_return_t rc; unsigned int set= 1; int32_t timeout; memcached_st *mclone= memcached_clone(NULL, memc); @@ -2397,7 +2397,7 @@ static test_return_t user_supplied_bug11(memcached_st *memc) */ static test_return_t user_supplied_bug12(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; uint32_t flags; size_t value_length; char *value; @@ -2446,7 +2446,7 @@ static test_return_t user_supplied_bug13(memcached_st *memc) { char key[] = "key34567890"; char *overflow; - memcached_return rc; + memcached_return_t rc; size_t overflowSize; char commandFirst[]= "set key34567890 0 0 "; @@ -2484,7 +2484,7 @@ static test_return_t user_supplied_bug14(memcached_st *memc) { size_t setter= 1; memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, setter); - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; char *value; size_t value_length= 18000; @@ -2528,7 +2528,7 @@ static test_return_t user_supplied_bug14(memcached_st *memc) static test_return_t user_supplied_bug15(memcached_st *memc) { uint32_t x; - memcached_return rc; + memcached_return_t rc; const char *key= "mykey"; char *value; size_t length; @@ -2565,7 +2565,7 @@ static test_return_t user_supplied_bug15(memcached_st *memc) /* Check the return sizes on FLAGS to make sure it stores 32bit unsigned values correctly */ static test_return_t user_supplied_bug16(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "mykey"; char *value; size_t length; @@ -2592,7 +2592,7 @@ static test_return_t user_supplied_bug16(memcached_st *memc) /* Check the validity of chinese key*/ static test_return_t user_supplied_bug17(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "豆瓣"; const char *value="我们在炎热抑郁的夏天无法停止豆瓣"; char *value2; @@ -2625,7 +2625,7 @@ static test_return_t user_supplied_bug19(memcached_st *memc) { memcached_st *m; memcached_server_st *s; - memcached_return res; + memcached_return_t res; (void)memc; @@ -2644,7 +2644,7 @@ static test_return_t user_supplied_bug19(memcached_st *memc) /* CAS test from Andei */ static test_return_t user_supplied_bug20(memcached_st *memc) { - memcached_return status; + memcached_return_t status; memcached_result_st *result, result_obj; const char *key = "abc"; size_t key_len = strlen("abc"); @@ -2676,7 +2676,7 @@ static test_return_t user_supplied_bug20(memcached_st *memc) #include "ketama_test_cases.h" static test_return_t user_supplied_bug18(memcached_st *trash) { - memcached_return rc; + memcached_return_t rc; uint64_t value; int x; memcached_server_st *server_pool; @@ -2749,7 +2749,7 @@ static void fail(int unused __attribute__((unused))) static test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count) { - memcached_return rc; + memcached_return_t rc; unsigned int x; char **keys; size_t* key_lengths; @@ -2799,7 +2799,7 @@ static test_return_t _user_supplied_bug21(memcached_st* memc, size_t key_count) return TEST_SUCCESS; } -static memcached_return pre_binary(memcached_st *memc); +static memcached_return_t pre_binary(memcached_st *memc); static test_return_t user_supplied_bug21(memcached_st *memc) { @@ -2823,7 +2823,7 @@ static test_return_t auto_eject_hosts(memcached_st *trash) { (void) trash; - memcached_return rc; + memcached_return_t rc; memcached_st *memc= memcached_create(NULL); test_truth(memc); @@ -2893,7 +2893,7 @@ static test_return_t output_ketama_weighted_keys(memcached_st *trash) { (void) trash; - memcached_return rc; + memcached_return_t rc; memcached_st *memc= memcached_create(NULL); test_truth(memc); @@ -3051,7 +3051,7 @@ static test_return_t string_alloc_append(memcached_st *memc) for (x= 0; x < 1024; x++) { - memcached_return rc; + memcached_return_t rc; rc= memcached_string_append(string, buffer, SMALL_STRING_LEN); test_truth(rc == MEMCACHED_SUCCESS); } @@ -3063,7 +3063,7 @@ static test_return_t string_alloc_append(memcached_st *memc) static test_return_t string_alloc_append_toobig(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; unsigned int x; char buffer[SMALL_STRING_LEN]; memcached_string_st *string; @@ -3136,7 +3136,7 @@ static test_return_t generate_data(memcached_st *memc) static test_return_t generate_data_with_stats(memcached_st *memc) { memcached_stat_st *stat_p; - memcached_return rc; + memcached_return_t rc; uint32_t host_index= 0; execute_set(memc, global_pairs, global_count); @@ -3171,7 +3171,7 @@ static test_return_t generate_buffer_data(memcached_st *memc) static test_return_t get_read_count(memcached_st *memc) { unsigned int x; - memcached_return rc; + memcached_return_t rc; memcached_st *memc_clone; memc_clone= memcached_clone(NULL, memc); @@ -3206,7 +3206,7 @@ static test_return_t get_read_count(memcached_st *memc) static test_return_t get_read(memcached_st *memc) { unsigned int x; - memcached_return rc; + memcached_return_t rc; { char *return_value; @@ -3231,7 +3231,7 @@ static test_return_t get_read(memcached_st *memc) static test_return_t mget_read(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; rc= memcached_mget(memc, global_keys, global_keys_length, global_count); test_truth(rc == MEMCACHED_SUCCESS); @@ -3242,7 +3242,7 @@ static test_return_t mget_read(memcached_st *memc) static test_return_t mget_read_result(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; rc= memcached_mget(memc, global_keys, global_keys_length, global_count); test_truth(rc == MEMCACHED_SUCCESS); @@ -3267,9 +3267,9 @@ static test_return_t mget_read_result(memcached_st *memc) static test_return_t mget_read_function(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; unsigned int counter; - memcached_execute_function callbacks[1]; + memcached_execute_fn callbacks[1]; rc= memcached_mget(memc, global_keys, global_keys_length, global_count); test_truth(rc == MEMCACHED_SUCCESS); @@ -3312,7 +3312,7 @@ static test_return_t delete_buffer_generate(memcached_st *memc) static test_return_t add_host_test1(memcached_st *memc) { unsigned int x; - memcached_return rc; + memcached_return_t rc; char servername[]= "0.example.com"; memcached_server_st *servers; @@ -3341,16 +3341,16 @@ static test_return_t add_host_test1(memcached_st *memc) return TEST_SUCCESS; } -static memcached_return pre_nonblock(memcached_st *memc) +static memcached_return_t pre_nonblock(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); return MEMCACHED_SUCCESS; } -static memcached_return pre_nonblock_binary(memcached_st *memc) +static memcached_return_t pre_nonblock_binary(memcached_st *memc) { - memcached_return rc= MEMCACHED_FAILURE; + memcached_return_t rc= MEMCACHED_FAILURE; memcached_st *memc_clone; memc_clone= memcached_clone(NULL, memc); @@ -3371,14 +3371,14 @@ static memcached_return pre_nonblock_binary(memcached_st *memc) return rc; } -static memcached_return pre_murmur(memcached_st *memc) +static memcached_return_t pre_murmur(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MURMUR); return MEMCACHED_SUCCESS; } -static memcached_return pre_jenkins(memcached_st *memc) +static memcached_return_t pre_jenkins(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_JENKINS); @@ -3386,21 +3386,21 @@ static memcached_return pre_jenkins(memcached_st *memc) } -static memcached_return pre_md5(memcached_st *memc) +static memcached_return_t pre_md5(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_MD5); return MEMCACHED_SUCCESS; } -static memcached_return pre_crc(memcached_st *memc) +static memcached_return_t pre_crc(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_CRC); return MEMCACHED_SUCCESS; } -static memcached_return pre_hsieh(memcached_st *memc) +static memcached_return_t pre_hsieh(memcached_st *memc) { #ifdef HAVE_HSIEH_HASH memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH); @@ -3411,37 +3411,37 @@ static memcached_return pre_hsieh(memcached_st *memc) #endif } -static memcached_return pre_hash_fnv1_64(memcached_st *memc) +static memcached_return_t pre_hash_fnv1_64(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1_64); return MEMCACHED_SUCCESS; } -static memcached_return pre_hash_fnv1a_64(memcached_st *memc) +static memcached_return_t pre_hash_fnv1a_64(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_64); return MEMCACHED_SUCCESS; } -static memcached_return pre_hash_fnv1_32(memcached_st *memc) +static memcached_return_t pre_hash_fnv1_32(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1_32); return MEMCACHED_SUCCESS; } -static memcached_return pre_hash_fnv1a_32(memcached_st *memc) +static memcached_return_t pre_hash_fnv1a_32(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_FNV1A_32); return MEMCACHED_SUCCESS; } -static memcached_return pre_behavior_ketama(memcached_st *memc) +static memcached_return_t pre_behavior_ketama(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; uint64_t value; rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA, 1); @@ -3453,9 +3453,9 @@ static memcached_return pre_behavior_ketama(memcached_st *memc) return MEMCACHED_SUCCESS; } -static memcached_return pre_behavior_ketama_weighted(memcached_st *memc) +static memcached_return_t pre_behavior_ketama_weighted(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; uint64_t value; rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED, 1); @@ -3472,9 +3472,9 @@ static memcached_return pre_behavior_ketama_weighted(memcached_st *memc) return MEMCACHED_SUCCESS; } -static memcached_return pre_binary(memcached_st *memc) +static memcached_return_t pre_binary(memcached_st *memc) { - memcached_return rc= MEMCACHED_FAILURE; + memcached_return_t rc= MEMCACHED_FAILURE; memcached_st *memc_clone; memc_clone= memcached_clone(NULL, memc); @@ -3495,7 +3495,7 @@ static memcached_return pre_binary(memcached_st *memc) return rc; } -static memcached_return pre_replication(memcached_st *memc) +static memcached_return_t pre_replication(memcached_st *memc) { if (pre_binary(memc) != MEMCACHED_SUCCESS) return MEMCACHED_FAILURE; @@ -3504,7 +3504,7 @@ static memcached_return pre_replication(memcached_st *memc) * Make sure that we store the item on all servers * (master + replicas == number of servers) */ - memcached_return rc; + memcached_return_t rc; rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, memc->number_of_hosts - 1); assert(rc == MEMCACHED_SUCCESS); @@ -3513,9 +3513,9 @@ static memcached_return pre_replication(memcached_st *memc) return rc; } -static memcached_return pre_replication_noblock(memcached_st *memc) +static memcached_return_t pre_replication_noblock(memcached_st *memc) { - memcached_return rc= MEMCACHED_FAILURE; + memcached_return_t rc= MEMCACHED_FAILURE; if (pre_replication(memc) == MEMCACHED_SUCCESS && pre_nonblock(memc) == MEMCACHED_SUCCESS) rc= MEMCACHED_SUCCESS; @@ -3547,9 +3547,9 @@ static void *my_calloc(memcached_st *ptr __attribute__((unused)), size_t nelem, return calloc(nelem, size); } -static memcached_return set_prefix(memcached_st *memc) +static memcached_return_t set_prefix(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "mine"; char *value; @@ -3617,15 +3617,15 @@ static memcached_return set_prefix(memcached_st *memc) } #ifdef MEMCACHED_ENABLE_DEPRECATED -static memcached_return deprecated_set_memory_alloc(memcached_st *memc) +static memcached_return_t deprecated_set_memory_alloc(memcached_st *memc) { void *test_ptr= NULL; void *cb_ptr= NULL; { - memcached_malloc_function malloc_cb= - (memcached_malloc_function)my_malloc; + memcached_malloc_fn malloc_cb= + (memcached_malloc_fn)my_malloc; cb_ptr= *(void **)&malloc_cb; - memcached_return rc; + memcached_return_t rc; rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_MALLOC_FUNCTION, cb_ptr); assert(rc == MEMCACHED_SUCCESS); @@ -3635,10 +3635,10 @@ static memcached_return deprecated_set_memory_alloc(memcached_st *memc) } { - memcached_realloc_function realloc_cb= - (memcached_realloc_function)my_realloc; + memcached_realloc_fn realloc_cb= + (memcached_realloc_fn)my_realloc; cb_ptr= *(void **)&realloc_cb; - memcached_return rc; + memcached_return_t rc; rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_REALLOC_FUNCTION, cb_ptr); assert(rc == MEMCACHED_SUCCESS); @@ -3648,10 +3648,10 @@ static memcached_return deprecated_set_memory_alloc(memcached_st *memc) } { - memcached_free_function free_cb= - (memcached_free_function)my_free; + memcached_free_fn free_cb= + (memcached_free_fn)my_free; cb_ptr= *(void **)&free_cb; - memcached_return rc; + memcached_return_t rc; rc= memcached_callback_set(memc, MEMCACHED_CALLBACK_FREE_FUNCTION, cb_ptr); assert(rc == MEMCACHED_SUCCESS); @@ -3663,9 +3663,9 @@ static memcached_return deprecated_set_memory_alloc(memcached_st *memc) } #endif -static memcached_return set_memory_alloc(memcached_st *memc) +static memcached_return_t set_memory_alloc(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; rc= memcached_set_memory_allocators(memc, NULL, my_free, my_realloc, my_calloc); assert(rc == MEMCACHED_FAILURE); @@ -3673,10 +3673,10 @@ static memcached_return set_memory_alloc(memcached_st *memc) rc= memcached_set_memory_allocators(memc, my_malloc, my_free, my_realloc, my_calloc); - memcached_malloc_function mem_malloc; - memcached_free_function mem_free; - memcached_realloc_function mem_realloc; - memcached_calloc_function mem_calloc; + memcached_malloc_fn mem_malloc; + memcached_free_fn mem_free; + memcached_realloc_fn mem_realloc; + memcached_calloc_fn mem_calloc; memcached_get_memory_allocators(memc, &mem_malloc, &mem_free, &mem_realloc, &mem_calloc); @@ -3688,25 +3688,25 @@ static memcached_return set_memory_alloc(memcached_st *memc) return MEMCACHED_SUCCESS; } -static memcached_return enable_consistent(memcached_st *memc) +static memcached_return_t enable_consistent(memcached_st *memc) { - memcached_server_distribution value= MEMCACHED_DISTRIBUTION_CONSISTENT; - memcached_hash hash; + memcached_server_distribution_t value= MEMCACHED_DISTRIBUTION_CONSISTENT; + memcached_hash_t hash; memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, value); if (pre_hsieh(memc) != MEMCACHED_SUCCESS) return MEMCACHED_FAILURE; - value= (memcached_server_distribution)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION); + value= (memcached_server_distribution_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_DISTRIBUTION); assert(value == MEMCACHED_DISTRIBUTION_CONSISTENT); - hash= (memcached_hash)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH); + hash= (memcached_hash_t)memcached_behavior_get(memc, MEMCACHED_BEHAVIOR_HASH); assert(hash == MEMCACHED_HASH_HSIEH); return MEMCACHED_SUCCESS; } -static memcached_return enable_cas(memcached_st *memc) +static memcached_return_t enable_cas(memcached_st *memc) { unsigned int set= 1; @@ -3723,7 +3723,7 @@ static memcached_return enable_cas(memcached_st *memc) return MEMCACHED_FAILURE; } -static memcached_return check_for_1_2_3(memcached_st *memc) +static memcached_return_t check_for_1_2_3(memcached_st *memc) { memcached_version(memc); @@ -3734,9 +3734,9 @@ static memcached_return check_for_1_2_3(memcached_st *memc) return MEMCACHED_FAILURE; } -static memcached_return pre_unix_socket(memcached_st *memc) +static memcached_return_t pre_unix_socket(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; struct stat buf; memcached_server_list_free(memc->hosts); @@ -3751,7 +3751,7 @@ static memcached_return pre_unix_socket(memcached_st *memc) return rc; } -static memcached_return pre_nodelay(memcached_st *memc) +static memcached_return_t pre_nodelay(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NO_BLOCK, 0); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 0); @@ -3759,7 +3759,7 @@ static memcached_return pre_nodelay(memcached_st *memc) return MEMCACHED_SUCCESS; } -static memcached_return pre_settimer(memcached_st *memc) +static memcached_return_t pre_settimer(memcached_st *memc) { memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_SND_TIMEOUT, 1000); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_RCV_TIMEOUT, 1000); @@ -3767,7 +3767,7 @@ static memcached_return pre_settimer(memcached_st *memc) return MEMCACHED_SUCCESS; } -static memcached_return poll_timeout(memcached_st *memc) +static memcached_return_t poll_timeout(memcached_st *memc) { size_t timeout; @@ -3784,7 +3784,7 @@ static memcached_return poll_timeout(memcached_st *memc) static test_return_t noreply_test(memcached_st *memc) { - memcached_return ret; + memcached_return_t ret; ret= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1); test_truth(ret == MEMCACHED_SUCCESS); ret= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1); @@ -3910,7 +3910,7 @@ static test_return_t noreply_test(memcached_st *memc) static test_return_t analyzer_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; memcached_stat_st *memc_stat; memcached_analysis_st *report; @@ -3929,7 +3929,7 @@ static test_return_t analyzer_test(memcached_st *memc) } /* Count the objects */ -static memcached_return callback_dump_counter(memcached_st *ptr __attribute__((unused)), +static memcached_return_t callback_dump_counter(memcached_st *ptr __attribute__((unused)), const char *key __attribute__((unused)), size_t key_length __attribute__((unused)), void *context) @@ -3943,9 +3943,9 @@ static memcached_return callback_dump_counter(memcached_st *ptr __attribute__((u static test_return_t dump_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; uint32_t counter= 0; - memcached_dump_func callbacks[1]; + memcached_dump_fn callbacks[1]; test_return_t main_rc; callbacks[0]= &callback_dump_counter; @@ -3985,7 +3985,7 @@ static test_return_t connection_pool_test(memcached_st *memc) memcached_pool_st* pool= memcached_pool_create(memc, 5, 10); test_truth(pool != NULL); memcached_st* mmc[10]; - memcached_return rc; + memcached_return_t rc; for (int x= 0; x < 10; ++x) { mmc[x]= memcached_pool_pop(pool, false, &rc); @@ -4054,7 +4054,7 @@ static test_return_t connection_pool_test(memcached_st *memc) static test_return_t replication_set_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; memcached_st *memc_clone= memcached_clone(NULL, memc); memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0); @@ -4101,7 +4101,7 @@ static test_return_t replication_set_test(memcached_st *memc) static test_return_t replication_get_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; /* * Don't do the following in your code. I am abusing the internal details @@ -4133,7 +4133,7 @@ static test_return_t replication_get_test(memcached_st *memc) static test_return_t replication_mget_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; memcached_st *memc_clone= memcached_clone(NULL, memc); memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 0); @@ -4202,7 +4202,7 @@ static test_return_t replication_mget_test(memcached_st *memc) static test_return_t replication_randomize_mget_test(memcached_st *memc) { memcached_result_st result_obj; - memcached_return rc; + memcached_return_t rc; memcached_st *memc_clone= memcached_clone(NULL, memc); memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 3); memcached_behavior_set(memc_clone, MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ, 1); @@ -4241,7 +4241,7 @@ static test_return_t replication_randomize_mget_test(memcached_st *memc) static test_return_t replication_delete_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; memcached_st *memc_clone= memcached_clone(NULL, memc); /* Delete the items from all of the servers except 1 */ uint64_t repl= memcached_behavior_get(memc, @@ -4337,7 +4337,7 @@ static test_return_t post_udp_op_check(memcached_st *memc, uint16_t *expected_re ** There is a little bit of a hack here, instead of removing ** the servers, I just set num host to 0 and them add then new udp servers **/ -static memcached_return init_udp(memcached_st *memc) +static memcached_return_t init_udp(memcached_st *memc) { memcached_version(memc); /* For the time being, only support udp test for >= 1.2.6 && < 1.3 */ @@ -4363,7 +4363,7 @@ static memcached_return init_udp(memcached_st *memc) return MEMCACHED_SUCCESS; } -static memcached_return binary_init_udp(memcached_st *memc) +static memcached_return_t binary_init_udp(memcached_st *memc) { pre_binary(memc); return init_udp(memc); @@ -4419,7 +4419,7 @@ static test_return_t udp_set_test(memcached_st *memc) unsigned int num_iters= 1025; //request id rolls over at 1024 for (x= 0; x < num_iters;x++) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize"; uint16_t *expected_ids= get_udp_request_ids(memc); @@ -4459,7 +4459,7 @@ static test_return_t udp_buffered_set_test(memcached_st *memc) static test_return_t udp_set_too_big_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "bar"; char value[MAX_UDP_DATAGRAM_LENGTH]; uint16_t *expected_ids= get_udp_request_ids(memc); @@ -4476,7 +4476,7 @@ static test_return_t udp_delete_test(memcached_st *memc) unsigned int num_iters= 1025; //request id rolls over at 1024 for (x= 0; x < num_iters;x++) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; uint16_t *expected_ids=get_udp_request_ids(memc); unsigned int server_key= memcached_generate_hash(memc, key, strlen(key)); @@ -4507,7 +4507,7 @@ static test_return_t udp_buffered_delete_test(memcached_st *memc) static test_return_t udp_verbosity_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; uint16_t *expected_ids= get_udp_request_ids(memc); unsigned int x; for (x= 0; x < memc->number_of_hosts;x++) @@ -4527,7 +4527,7 @@ static test_return_t udp_quit_test(memcached_st *memc) static test_return_t udp_flush_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; uint16_t *expected_ids= get_udp_request_ids(memc); unsigned int x; for (x= 0; x < memc->number_of_hosts;x++) @@ -4540,7 +4540,7 @@ static test_return_t udp_flush_test(memcached_st *memc) static test_return_t udp_incr_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "incr"; const char *value= "1"; rc= memcached_set(memc, key, strlen(key), @@ -4559,7 +4559,7 @@ static test_return_t udp_incr_test(memcached_st *memc) static test_return_t udp_decr_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "decr"; const char *value= "1"; rc= memcached_set(memc, key, strlen(key), @@ -4580,7 +4580,7 @@ static test_return_t udp_decr_test(memcached_st *memc) static test_return_t udp_stat_test(memcached_st *memc) { memcached_stat_st * rv= NULL; - memcached_return rc; + memcached_return_t rc; char args[]= ""; uint16_t *expected_ids = get_udp_request_ids(memc); rv = memcached_stat(memc, args, &rc); @@ -4591,7 +4591,7 @@ static test_return_t udp_stat_test(memcached_st *memc) static test_return_t udp_version_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; uint16_t *expected_ids = get_udp_request_ids(memc); rc = memcached_version(memc); test_truth(rc == MEMCACHED_NOT_SUPPORTED); @@ -4600,7 +4600,7 @@ static test_return_t udp_version_test(memcached_st *memc) static test_return_t udp_get_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; size_t vlen; uint16_t *expected_ids = get_udp_request_ids(memc); @@ -4635,11 +4635,11 @@ static test_return_t udp_mixed_io_test(memcached_st *memc) static test_return_t hsieh_avaibility_test (memcached_st *memc) { - memcached_return expected_rc= MEMCACHED_FAILURE; + memcached_return_t expected_rc= MEMCACHED_FAILURE; #ifdef HAVE_HSIEH_HASH expected_rc= MEMCACHED_SUCCESS; #endif - memcached_return rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, + memcached_return_t rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_HASH, (uint64_t)MEMCACHED_HASH_HSIEH); test_truth(rc == expected_rc); return TEST_SUCCESS; @@ -4887,7 +4887,7 @@ static test_return_t jenkins_run (memcached_st *memc __attribute__((unused))) static test_return_t ketama_compatibility_libmemcached(memcached_st *trash) { - memcached_return rc; + memcached_return_t rc; uint64_t value; int x; memcached_server_st *server_pool; @@ -4946,7 +4946,7 @@ static test_return_t ketama_compatibility_libmemcached(memcached_st *trash) static test_return_t ketama_compatibility_spymemcached(memcached_st *trash) { - memcached_return rc; + memcached_return_t rc; uint64_t value; int x; memcached_server_st *server_pool; @@ -5008,7 +5008,7 @@ static test_return_t regression_bug_434484(memcached_st *memc) if (pre_binary(memc) != MEMCACHED_SUCCESS) return TEST_SKIPPED; - memcached_return ret; + memcached_return_t ret; const char *key= "regression_bug_434484"; size_t keylen= strlen(key); @@ -5030,9 +5030,9 @@ static test_return_t regression_bug_434843(memcached_st *memc) if (pre_binary(memc) != MEMCACHED_SUCCESS) return TEST_SKIPPED; - memcached_return rc; + memcached_return_t rc; unsigned int counter= 0; - memcached_execute_function callbacks[1]= { [0]= &callback_counter }; + memcached_execute_fn callbacks[1]= { [0]= &callback_counter }; /* * I only want to hit only _one_ server so I know the number of requests I'm @@ -5094,7 +5094,7 @@ static test_return_t regression_bug_434843(memcached_st *memc) static test_return_t regression_bug_434843_buffered(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_BUFFER_REQUESTS, 1); assert(rc == MEMCACHED_SUCCESS); @@ -5103,7 +5103,7 @@ static test_return_t regression_bug_434843_buffered(memcached_st *memc) static test_return_t regression_bug_421108(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; memcached_stat_st *memc_stat= memcached_stat(memc, NULL, &rc); assert(rc == MEMCACHED_SUCCESS); @@ -5144,7 +5144,7 @@ static test_return_t regression_bug_421108(memcached_st *memc) */ static test_return_t regression_bug_442914(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NOREPLY, 1); assert(rc == MEMCACHED_SUCCESS); memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, 1); @@ -5181,7 +5181,7 @@ static test_return_t regression_bug_447342(memcached_st *memc) if (memc->number_of_hosts < 3 || pre_replication(memc) != MEMCACHED_SUCCESS) return TEST_SKIPPED; - memcached_return rc; + memcached_return_t rc; rc= memcached_behavior_set(memc, MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS, 2); assert(rc == MEMCACHED_SUCCESS); @@ -5222,7 +5222,7 @@ static test_return_t regression_bug_447342(memcached_st *memc) assert(rc == MEMCACHED_SUCCESS); unsigned int counter= 0; - memcached_execute_function callbacks[1]= { [0]= &callback_counter }; + memcached_execute_fn callbacks[1]= { [0]= &callback_counter }; rc= memcached_fetch_execute(memc, callbacks, (void *)&counter, 1); /* Verify that we received all of the key/value pairs */ assert(counter == (unsigned int)max_keys); @@ -5308,7 +5308,7 @@ static test_return_t regression_bug_463297(memcached_st *memc) assert(memcached_delete(memc_clone, "foo", 3, 1) == MEMCACHED_INVALID_ARGUMENTS); /* If we don't know the server version, we should get a protocol error */ - memcached_return rc= memcached_delete(memc, "foo", 3, 1); + memcached_return_t rc= memcached_delete(memc, "foo", 3, 1); /* but there is a bug in some of the memcached servers (1.4) that treats * the counter as noreply so it doesn't send the proper error message */ @@ -5347,7 +5347,7 @@ static test_return_t regression_bug_463297(memcached_st *memc) */ static test_return_t test_get_last_disconnect(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; memcached_server_st *disconnected_server; /* With the working set of server */ @@ -5398,7 +5398,7 @@ static test_return_t test_get_last_disconnect(memcached_st *memc) */ static test_return_t wrong_failure_counter_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; /* Set value to force connection to the server */ const char *key= "marmotte"; diff --git a/tests/plus.cpp b/tests/plus.cpp index 6ffd090f..ee898d4e 100644 --- a/tests/plus.cpp +++ b/tests/plus.cpp @@ -29,7 +29,7 @@ extern "C" { test_return_t mget_result_function(memcached_st *memc); test_return_t basic_behavior(memcached_st *memc); test_return_t mget_test(memcached_st *memc); - memcached_return callback_counter(memcached_st *, + memcached_return_t callback_counter(memcached_st *, memcached_result_st *, void *context); void *world_create(void); @@ -152,9 +152,9 @@ test_return_t basic_master_key_test(memcached_st *memc) } /* Count the results */ -memcached_return callback_counter(memcached_st *, - memcached_result_st *, - void *context) +memcached_return_t callback_counter(memcached_st *, + memcached_result_st *, + void *context) { unsigned int *counter= static_cast(context); @@ -187,7 +187,7 @@ test_return_t mget_result_function(memcached_st *memc) values.push_back(&val2); values.push_back(&val3); unsigned int counter; - memcached_execute_function callbacks[1]; + memcached_execute_fn callbacks[1]; /* We need to empty the server before we continue the test */ rc= mc.flush(0); @@ -210,7 +210,7 @@ test_return_t mget_test(memcached_st *memc) { Memcache mc(memc); bool rc; - memcached_return mc_rc; + memcached_return_t mc_rc; vector keys; vector< vector *> values; keys.reserve(3); diff --git a/tests/test.c b/tests/test.c index 7480d29d..7a5e3132 100644 --- a/tests/test.c +++ b/tests/test.c @@ -95,7 +95,7 @@ int main(int argc, char *argv[]) { unsigned int loop; memcached_st *memc; - memcached_return rc; + memcached_return_t rc; struct timeval start_time, end_time; long int load_time; diff --git a/tests/test.h b/tests/test.h index 18da50f2..b002cd1e 100644 --- a/tests/test.h +++ b/tests/test.h @@ -28,8 +28,8 @@ struct test_st { struct collection_st { const char *name; - memcached_return (*pre)(memcached_st *memc); - memcached_return (*post)(memcached_st *memc); + memcached_return_t (*pre)(memcached_st *memc); + memcached_return_t (*post)(memcached_st *memc); test_st *tests; }; diff --git a/tests/udp.c b/tests/udp.c index 3aa48a01..a78c5822 100644 --- a/tests/udp.c +++ b/tests/udp.c @@ -21,7 +21,7 @@ void world_destroy(void *p); test_return_t set_test(memcached_st *memc) { - memcached_return rc; + memcached_return_t rc; const char *key= "foo"; const char *value= "when we sanitize";