From c38f53f67c27b36858e456fcb86a725d5c27b977 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Wed, 16 Dec 2009 16:11:59 -0800 Subject: [PATCH] More const correctness. --- Makefile.am | 9 +++--- libmemcached/behavior.c | 4 +-- libmemcached/behavior.h | 4 +-- libmemcached/callback.c | 4 +-- libmemcached/callback.h | 4 +-- libmemcached/common.h | 3 +- libmemcached/get.h | 48 ++++++++++++++++--------------- libmemcached/io.h | 7 +++-- libmemcached/memcached_util.h | 2 +- libmemcached/pool.h | 8 +++--- libmemcached/protocol_handler.h | 2 +- libmemcached/result.h | 4 +-- libmemcached/server.c | 2 +- libmemcached/server.h | 23 ++++++++++----- libmemcached/storage.h | 50 ++++++++++++++++----------------- libmemcached/types.h | 4 ++- 16 files changed, 97 insertions(+), 81 deletions(-) diff --git a/Makefile.am b/Makefile.am index 7aa35f03..e687f9ce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -35,10 +35,11 @@ generic: rpm: all dist generic fedora -clean-merge: - find ./ | grep \.orig | xargs rm - find ./ | grep \.rej | xargs rm - find ./ | grep \~$ | xargs rm +merge-clean: + find ./ | $(GREP) \.orig | xargs rm -f + find ./ | $(GREP) \.rej | xargs rm -f + find ./ | $(GREP) \~$$ | xargs rm -f + bzr unknowns hudson-valgrind: all @(cd tests; ${MAKE} hudson-valgrind) diff --git a/libmemcached/behavior.c b/libmemcached/behavior.c index 37c9f529..e020258d 100644 --- a/libmemcached/behavior.c +++ b/libmemcached/behavior.c @@ -22,7 +22,7 @@ */ memcached_return_t memcached_behavior_set(memcached_st *ptr, - memcached_behavior_t flag, + const memcached_behavior_t flag, uint64_t data) { switch (flag) @@ -196,7 +196,7 @@ memcached_return_t memcached_behavior_set(memcached_st *ptr, } uint64_t memcached_behavior_get(memcached_st *ptr, - memcached_behavior_t flag) + const memcached_behavior_t flag) { switch (flag) { diff --git a/libmemcached/behavior.h b/libmemcached/behavior.h index 14cbc3aa..5abc0331 100644 --- a/libmemcached/behavior.h +++ b/libmemcached/behavior.h @@ -17,10 +17,10 @@ extern "C" { #endif LIBMEMCACHED_API -memcached_return_t memcached_behavior_set(memcached_st *ptr, memcached_behavior_t flag, uint64_t data); +memcached_return_t memcached_behavior_set(memcached_st *ptr, const memcached_behavior_t flag, uint64_t data); LIBMEMCACHED_API -uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior_t flag); +uint64_t memcached_behavior_get(memcached_st *ptr, const memcached_behavior_t flag); #ifdef __cplusplus diff --git a/libmemcached/callback.c b/libmemcached/callback.c index b0ddfc2b..aadde22c 100644 --- a/libmemcached/callback.c +++ b/libmemcached/callback.c @@ -19,7 +19,7 @@ */ memcached_return_t memcached_callback_set(memcached_st *ptr, - memcached_callback_t flag, + const memcached_callback_t flag, void *data) { switch (flag) @@ -113,7 +113,7 @@ memcached_return_t memcached_callback_set(memcached_st *ptr, } void *memcached_callback_get(memcached_st *ptr, - memcached_callback_t flag, + const memcached_callback_t flag, memcached_return_t *error) { memcached_return_t local_error; diff --git a/libmemcached/callback.h b/libmemcached/callback.h index 0719a66f..de64a199 100644 --- a/libmemcached/callback.h +++ b/libmemcached/callback.h @@ -18,11 +18,11 @@ extern "C" { LIBMEMCACHED_API memcached_return_t memcached_callback_set(memcached_st *ptr, - memcached_callback_t flag, + const memcached_callback_t flag, void *data); LIBMEMCACHED_API void *memcached_callback_get(memcached_st *ptr, - memcached_callback_t flag, + const memcached_callback_t flag, memcached_return_t *error); #ifdef __cplusplus diff --git a/libmemcached/common.h b/libmemcached/common.h index c9d7cf81..97899ea9 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -62,7 +62,8 @@ #include "libmemcached/byteorder.h" /* string value */ -struct memcached_continuum_item_st { +struct memcached_continuum_item_st +{ uint32_t index; uint32_t value; }; diff --git a/libmemcached/get.h b/libmemcached/get.h index bb04a154..2e5b2f99 100644 --- a/libmemcached/get.h +++ b/libmemcached/get.h @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See @@ -18,42 +18,44 @@ extern "C" { /* Public defines */ LIBMEMCACHED_API -char *memcached_get(memcached_st *ptr, +char *memcached_get(memcached_st *ptr, const char *key, size_t key_length, - size_t *value_length, + size_t *value_length, uint32_t *flags, memcached_return_t *error); LIBMEMCACHED_API -memcached_return_t memcached_mget(memcached_st *ptr, - const char * const *keys, - const size_t *key_length, +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, - const char *master_key, size_t master_key_length, - const char *key, size_t key_length, - size_t *value_length, +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_t *error); LIBMEMCACHED_API -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); +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, + const 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, +char *memcached_fetch(memcached_st *ptr, + char *key, + size_t *key_length, + size_t *value_length, + uint32_t *flags, memcached_return_t *error); LIBMEMCACHED_API -memcached_result_st *memcached_fetch_result(memcached_st *ptr, +memcached_result_st *memcached_fetch_result(memcached_st *ptr, memcached_result_st *result, memcached_return_t *error); @@ -61,10 +63,10 @@ LIBMEMCACHED_API memcached_return_t memcached_mget_execute(memcached_st *ptr, const char * const *keys, const size_t *key_length, - size_t number_of_keys, + const size_t number_of_keys, memcached_execute_fn *callback, void *context, - unsigned int number_of_callbacks); + const uint32_t number_of_callbacks); LIBMEMCACHED_API memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr, @@ -75,7 +77,7 @@ memcached_return_t memcached_mget_execute_by_key(memcached_st *ptr, size_t number_of_keys, memcached_execute_fn *callback, void *context, - unsigned int number_of_callbacks); + const uint32_t number_of_callbacks); #ifdef __cplusplus } diff --git a/libmemcached/io.h b/libmemcached/io.h index 03d63b55..2929aace 100644 --- a/libmemcached/io.h +++ b/libmemcached/io.h @@ -32,7 +32,8 @@ extern "C" { #define generate_udp_request_thread_id(A) (A) << UDP_REQUEST_ID_MSG_SIG_DIGITS #define UDP_REQUEST_ID_MAX_THREAD_ID get_thread_id_from_request_id(0xFFFF) -struct udp_datagram_header_st { +struct udp_datagram_header_st +{ uint16_t request_id; uint16_t sequence_number; uint16_t num_datagrams; @@ -50,8 +51,8 @@ memcached_return_t memcached_io_readline(memcached_server_st *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_t memcached_safe_read(memcached_server_st *ptr, - void *dta, +memcached_return_t memcached_safe_read(memcached_server_st *ptr, + void *dta, size_t size); /* Read a single response from the server */ memcached_return_t memcached_read_one_response(memcached_server_st *ptr, diff --git a/libmemcached/memcached_util.h b/libmemcached/memcached_util.h index c1a719d6..7b7c5e83 100644 --- a/libmemcached/memcached_util.h +++ b/libmemcached/memcached_util.h @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See diff --git a/libmemcached/pool.h b/libmemcached/pool.h index 84dab3dd..b6325f3e 100644 --- a/libmemcached/pool.h +++ b/libmemcached/pool.h @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See @@ -23,7 +23,7 @@ struct memcached_pool_st; typedef struct memcached_pool_st memcached_pool_st; LIBMEMCACHED_API -memcached_pool_st *memcached_pool_create(memcached_st* mmc, uint32_t initial, +memcached_pool_st *memcached_pool_create(memcached_st* mmc, uint32_t initial, uint32_t max); LIBMEMCACHED_API memcached_st* memcached_pool_destroy(memcached_pool_st* pool); @@ -32,8 +32,8 @@ memcached_st* memcached_pool_pop(memcached_pool_st* pool, bool block, memcached_return_t* rc); LIBMEMCACHED_API -memcached_return_t memcached_pool_push(memcached_pool_st* pool, - memcached_st* mmc); +memcached_return_t memcached_pool_push(memcached_pool_st* pool, + memcached_st* mmc); LIBMEMCACHED_API memcached_return_t memcached_pool_behavior_set(memcached_pool_st *ptr, diff --git a/libmemcached/protocol_handler.h b/libmemcached/protocol_handler.h index 5a820d4f..3fb00c98 100644 --- a/libmemcached/protocol_handler.h +++ b/libmemcached/protocol_handler.h @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See diff --git a/libmemcached/result.h b/libmemcached/result.h index 4b0c12e5..2602fce3 100644 --- a/libmemcached/result.h +++ b/libmemcached/result.h @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See @@ -37,7 +37,7 @@ void memcached_result_free(memcached_result_st *result); LIBMEMCACHED_API void memcached_result_reset(memcached_result_st *ptr); LIBMEMCACHED_API -memcached_result_st *memcached_result_create(memcached_st *ptr, +memcached_result_st *memcached_result_create(memcached_st *ptr, memcached_result_st *result); #define memcached_result_key_value(A) (A)->key #define memcached_result_key_length(A) (A)->key_length diff --git a/libmemcached/server.c b/libmemcached/server.c index 2cff36da..814962c7 100644 --- a/libmemcached/server.c +++ b/libmemcached/server.c @@ -18,7 +18,7 @@ memcached_server_st *memcached_server_create(memcached_st *memc, memcached_serve { if (ptr == NULL) { - ptr= (memcached_server_st *)calloc(1, sizeof(memcached_server_st)); + ptr= (memcached_server_st *)memc->call_calloc(memc, 1, sizeof(memcached_server_st)); if (!ptr) return NULL; /* MEMCACHED_MEMORY_ALLOCATION_FAILURE */ diff --git a/libmemcached/server.h b/libmemcached/server.h index f2d92dc1..0e38fdd1 100644 --- a/libmemcached/server.h +++ b/libmemcached/server.h @@ -60,8 +60,10 @@ memcached_return_t memcached_server_cursor(memcached_st *ptr, 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_t *error); +memcached_server_st *memcached_server_by_key(memcached_st *ptr, + const char *key, + size_t key_length, + memcached_return_t *error); LIBMEMCACHED_API const char *memcached_server_error(memcached_server_st *ptr); @@ -76,16 +78,23 @@ LIBMEMCACHED_API memcached_server_st *memcached_server_create(memcached_st *memc, memcached_server_st *ptr); LIBMEMCACHED_API -memcached_server_st *memcached_server_create_with(memcached_st *memc, memcached_server_st *host, - const char *hostname, in_port_t port, - uint32_t weight, memcached_connection_t type); +memcached_server_st *memcached_server_create_with(memcached_st *memc, + memcached_server_st *host, + const char *hostname, + in_port_t port, + uint32_t weight, + memcached_connection_t type); LIBMEMCACHED_API void memcached_server_free(memcached_server_st *ptr); + LIBMEMCACHED_API -memcached_server_st *memcached_server_clone(memcached_server_st *clone, memcached_server_st *ptr); +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_analysis_st *memcached_analyze(memcached_st *memc, + memcached_stat_st *memc_stat, memcached_return_t *error); LIBMEMCACHED_API diff --git a/libmemcached/storage.h b/libmemcached/storage.h index ec982ba0..8f233967 100644 --- a/libmemcached/storage.h +++ b/libmemcached/storage.h @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See @@ -20,85 +20,85 @@ extern "C" { /* All of the functions for adding data to the server */ LIBMEMCACHED_API -memcached_return_t memcached_set(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, +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_t memcached_add(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API memcached_return_t memcached_replace(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API -memcached_return_t memcached_append(memcached_st *ptr, +memcached_return_t memcached_append(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API -memcached_return_t memcached_prepend(memcached_st *ptr, +memcached_return_t memcached_prepend(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API -memcached_return_t memcached_cas(memcached_st *ptr, +memcached_return_t memcached_cas(memcached_st *ptr, const char *key, size_t key_length, - const char *value, size_t value_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas); LIBMEMCACHED_API -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, +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_t memcached_add_by_key(memcached_st *ptr, +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, + const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API -memcached_return_t memcached_replace_by_key(memcached_st *ptr, +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, + const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API -memcached_return_t memcached_prepend_by_key(memcached_st *ptr, +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, + const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API -memcached_return_t memcached_append_by_key(memcached_st *ptr, +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, + const char *value, size_t value_length, time_t expiration, uint32_t flags); LIBMEMCACHED_API -memcached_return_t memcached_cas_by_key(memcached_st *ptr, +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, + const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas); diff --git a/libmemcached/types.h b/libmemcached/types.h index 58f0887a..e01a47eb 100644 --- a/libmemcached/types.h +++ b/libmemcached/types.h @@ -38,7 +38,9 @@ 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); + const char *key, + size_t key_length, + void *context); typedef struct { memcached_execute_fn *callback; -- 2.30.2