From: Brian Aker Date: Tue, 20 May 2008 23:05:04 +0000 (-0700) Subject: Fixed all key methods to now take const char * (all previous code will work X-Git-Tag: 0.21~7 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=571fad579922f2b10873193500dfd0652f4fdc37;p=awesomized%2Flibmemcached Fixed all key methods to now take const char * (all previous code will work just fine). --- diff --git a/ChangeLog b/ChangeLog index 78af7501..f85b6295 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +0.21 + * Change of char * to const char * for all key based functions. + 0.20 Mon May 5 08:34:26 PDT 2008 * New consistent distribution tests. * Found a memory leak when a server constantly fails. diff --git a/docs/memcached_auto.pod b/docs/memcached_auto.pod index 27332e93..df0a8b58 100755 --- a/docs/memcached_auto.pod +++ b/docs/memcached_auto.pod @@ -12,13 +12,13 @@ C Client Library for memcached (libmemcached, -lmemcached) memcached_return memcached_increment (memcached_st *ptr, - char *key, size_t key_length, + const char *key, size_t key_length, unsigned int offset, uint64_t *value); memcached_return memcached_decrement (memcached_st *ptr, - char *key, size_t key_length, + const char *key, size_t key_length, unsigned int offset, uint64_t *value); diff --git a/docs/memcached_delete.pod b/docs/memcached_delete.pod index 18fec84b..41a55df9 100755 --- a/docs/memcached_delete.pod +++ b/docs/memcached_delete.pod @@ -12,13 +12,13 @@ C Client Library for memcached (libmemcached, -lmemcached) memcached_return memcached_delete (memcached_st *ptr, - char *key, size_t key_length, + const char *key, size_t key_length, time_t expiration); memcached_return memcached_delete_by_key (memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, time_t expiration); =head1 DESCRIPTION diff --git a/docs/memcached_get.pod b/docs/memcached_get.pod index 5557e7c3..df0ac779 100755 --- a/docs/memcached_get.pod +++ b/docs/memcached_get.pod @@ -16,7 +16,7 @@ C Client Library for memcached (libmemcached, -lmemcached) memcached_return *error); char *memcached_get (memcached_st *ptr, - char *key, size_t key_length, + const char *key, size_t key_length, size_t *value_length, uint32_t *flags, memcached_return *error); @@ -27,20 +27,20 @@ C Client Library for memcached (libmemcached, -lmemcached) unsigned int number_of_keys); char * memcached_get_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, + 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, - char *master_key, size_t master_key_length, + const char *master_key, size_t master_key_length, char **keys, size_t *key_length, unsigned int number_of_keys); char *memcached_fetch (memcached_st *ptr, - char *key, size_t *key_length, + const char *key, size_t *key_length, size_t *value_length, uint32_t *flags, memcached_return *error); diff --git a/docs/memcached_set.pod b/docs/memcached_set.pod index 6e962d38..5e7ac186 100755 --- a/docs/memcached_set.pod +++ b/docs/memcached_set.pod @@ -12,91 +12,91 @@ C Client Library for memcached (libmemcached, -lmemcached) memcached_return memcached_set (memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return memcached_add (memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return memcached_replace (memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return memcached_prepend(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags) memcached_return memcached_append(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags) memcached_return memcached_cas(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_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 memcached_set_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_add_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_replace_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_prepend_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_append_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_cas_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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); diff --git a/libmemcached/Makefile.am b/libmemcached/Makefile.am index 18cdf23a..550b4890 100644 --- a/libmemcached/Makefile.am +++ b/libmemcached/Makefile.am @@ -28,6 +28,7 @@ pkginclude_HEADERS= memcached.h \ memcached.hh \ libmemcached_config.h \ memcached_constants.h \ + memcached_get.h \ memcached_result.h \ memcached_server.h \ memcached_storage.h \ diff --git a/libmemcached/common.h b/libmemcached/common.h index b2406196..ad6ccd7d 100644 --- a/libmemcached/common.h +++ b/libmemcached/common.h @@ -80,24 +80,24 @@ typedef enum { } memcached_flags; /* Hashing algo */ -void md5_signature(unsigned char *key, unsigned int length, unsigned char *result); +void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result); uint32_t hash_crc32(const char *data, size_t data_len); -uint32_t hsieh_hash(char *key, size_t key_length); -uint32_t murmur_hash(char *key, size_t key_length); +uint32_t hsieh_hash(const char *key, size_t key_length); +uint32_t murmur_hash(const char *key, size_t key_length); memcached_return memcached_connect(memcached_server_st *ptr); memcached_return memcached_response(memcached_server_st *ptr, char *buffer, size_t buffer_length, memcached_result_st *result); -uint32_t memcached_generate_hash(memcached_st *ptr, char *key, size_t key_length); +uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length); void memcached_quit_server(memcached_server_st *ptr, uint8_t io_death); #define memcached_server_response_increment(A) (A)->cursor_active++ #define memcached_server_response_decrement(A) (A)->cursor_active-- #define memcached_server_response_reset(A) (A)->cursor_active=0 -memcached_return memcached_do(memcached_server_st *ptr, char *commmand, +memcached_return memcached_do(memcached_server_st *ptr, const char *commmand, size_t command_length, uint8_t with_flush); memcached_return memcached_version(memcached_st *ptr); memcached_return value_fetch(memcached_server_st *ptr, @@ -110,5 +110,5 @@ memcached_return memcachd_key_test(char **keys, size_t *key_length, memcached_return run_distribution(memcached_st *ptr); -uint32_t generate_hash(memcached_st *ptr, char *key, size_t key_length); +uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length); #endif /* __COMMON_H__ */ diff --git a/libmemcached/hsieh_hash.c b/libmemcached/hsieh_hash.c index 9f42a94d..e6c23cd9 100644 --- a/libmemcached/hsieh_hash.c +++ b/libmemcached/hsieh_hash.c @@ -17,7 +17,7 @@ +(uint32_t)(((const uint8_t *)(d))[0]) ) #endif -uint32_t hsieh_hash(char *key, size_t key_length) +uint32_t hsieh_hash(const char *key, size_t key_length) { uint32_t hash = 0, tmp; int rem; diff --git a/libmemcached/md5.c b/libmemcached/md5.c index 61f8d692..ef43035a 100644 --- a/libmemcached/md5.c +++ b/libmemcached/md5.c @@ -50,7 +50,7 @@ typedef struct { static void MD5Init (MD5_CTX *context); /* context */ static void MD5Update ( MD5_CTX *context, /* context */ - unsigned char *input, /* input block */ + const unsigned char *input, /* input block */ unsigned int inputLen); /* length of input block */ static void MD5Final ( unsigned char digest[16], /* message digest */ MD5_CTX *context); /* context */ @@ -128,7 +128,7 @@ Rotation is separate from addition to prevent recomputation. Just a simple method for getting the signature result must be == 16 */ -void md5_signature(unsigned char *key, unsigned int length, unsigned char *result) +void md5_signature(const unsigned char *key, unsigned int length, unsigned char *result) { MD5_CTX my_md5; @@ -157,7 +157,7 @@ static void MD5Init (MD5_CTX *context) /* context */ static void MD5Update ( MD5_CTX *context, /* context */ - unsigned char *input, /* input block */ + const unsigned char *input, /* input block */ unsigned int inputLen) /* length of input block */ { unsigned int i, idx, partLen; @@ -181,7 +181,7 @@ static void MD5Update ( MD5Transform(context->state, context->buffer); for (i = partLen; i + 63 < inputLen; i += 64) - MD5Transform (context->state, &input[i]); + MD5Transform (context->state, (unsigned char *)&input[i]); idx = 0; } diff --git a/libmemcached/memcached.h b/libmemcached/memcached.h index 3a1def48..b907809d 100644 --- a/libmemcached/memcached.h +++ b/libmemcached/memcached.h @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -106,14 +107,14 @@ memcached_st *memcached_create(memcached_st *ptr); void memcached_free(memcached_st *ptr); memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr); -memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length, +memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length, time_t expiration); memcached_return memcached_increment(memcached_st *ptr, - char *key, size_t key_length, + const char *key, size_t key_length, uint32_t offset, uint64_t *value); memcached_return memcached_decrement(memcached_st *ptr, - char *key, size_t key_length, + const char *key, size_t key_length, uint32_t offset, uint64_t *value); void memcached_stat_free(memcached_st *, memcached_stat_st *); @@ -127,21 +128,6 @@ char *memcached_strerror(memcached_st *ptr, memcached_return rc); memcached_return memcached_behavior_set(memcached_st *ptr, memcached_behavior flag, uint64_t data); uint64_t memcached_behavior_get(memcached_st *ptr, memcached_behavior flag); -/* Get functions */ -char *memcached_get(memcached_st *ptr, char *key, size_t key_length, - size_t *value_length, - uint32_t *flags, - memcached_return *error); -memcached_return memcached_mget(memcached_st *ptr, - char **keys, size_t *key_length, - unsigned int 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_result_st *memcached_fetch_result(memcached_st *ptr, - memcached_result_st *result, - memcached_return *error); - /* Server Public functions */ memcached_return memcached_server_add_udp(memcached_st *ptr, @@ -165,21 +151,9 @@ char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat, char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *stat, memcached_return *error); -char *memcached_get_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - 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, - char *master_key, size_t master_key_length, - char **keys, size_t *key_length, - unsigned int number_of_keys); - memcached_return memcached_delete_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, time_t expiration); memcached_return memcached_fetch_execute(memcached_st *ptr, diff --git a/libmemcached/memcached_auto.c b/libmemcached/memcached_auto.c index a607ed66..bc6adc0f 100644 --- a/libmemcached/memcached_auto.c +++ b/libmemcached/memcached_auto.c @@ -1,8 +1,8 @@ #include "common.h" static memcached_return memcached_auto(memcached_st *ptr, - char *verb, - char *key, size_t key_length, + const char *verb, + const char *key, size_t key_length, unsigned int offset, uint64_t *value) { @@ -17,7 +17,7 @@ static memcached_return memcached_auto(memcached_st *ptr, unlikely (ptr->hosts == NULL || ptr->number_of_hosts == 0) return MEMCACHED_NO_SERVERS; - if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test(&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED)) + if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test((char **)&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED)) return MEMCACHED_BAD_KEY_PROVIDED; server_key= memcached_generate_hash(ptr, key, key_length); @@ -62,7 +62,7 @@ static memcached_return memcached_auto(memcached_st *ptr, } memcached_return memcached_increment(memcached_st *ptr, - char *key, size_t key_length, + const char *key, size_t key_length, uint32_t offset, uint64_t *value) { @@ -76,7 +76,7 @@ memcached_return memcached_increment(memcached_st *ptr, } memcached_return memcached_decrement(memcached_st *ptr, - char *key, size_t key_length, + const char *key, size_t key_length, uint32_t offset, uint64_t *value) { diff --git a/libmemcached/memcached_delete.c b/libmemcached/memcached_delete.c index 37a28add..5df976ad 100644 --- a/libmemcached/memcached_delete.c +++ b/libmemcached/memcached_delete.c @@ -1,6 +1,6 @@ #include "common.h" -memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_length, +memcached_return memcached_delete(memcached_st *ptr, const char *key, size_t key_length, time_t expiration) { return memcached_delete_by_key(ptr, key, key_length, @@ -8,8 +8,8 @@ memcached_return memcached_delete(memcached_st *ptr, char *key, size_t key_lengt } memcached_return memcached_delete_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, + const char *master_key, size_t master_key_length, + const char *key, size_t key_length, time_t expiration) { char to_write; diff --git a/libmemcached/memcached_do.c b/libmemcached/memcached_do.c index c4bf574f..671b9fa3 100644 --- a/libmemcached/memcached_do.c +++ b/libmemcached/memcached_do.c @@ -1,6 +1,6 @@ #include "common.h" -memcached_return memcached_do(memcached_server_st *ptr, char *command, +memcached_return memcached_do(memcached_server_st *ptr, const char *command, size_t command_length, uint8_t with_flush) { memcached_return rc; diff --git a/libmemcached/memcached_get.c b/libmemcached/memcached_get.c index 852e90dd..a2f7716d 100644 --- a/libmemcached/memcached_get.c +++ b/libmemcached/memcached_get.c @@ -4,7 +4,8 @@ /* What happens if no servers exist? */ -char *memcached_get(memcached_st *ptr, char *key, size_t key_length, +char *memcached_get(memcached_st *ptr, const char *key, + size_t key_length, size_t *value_length, uint32_t *flags, memcached_return *error) @@ -14,8 +15,9 @@ char *memcached_get(memcached_st *ptr, char *key, size_t key_length, } char *memcached_get_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, + 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) @@ -29,7 +31,7 @@ char *memcached_get_by_key(memcached_st *ptr, *error= memcached_mget_by_key(ptr, master_key, master_key_length, - &key, &key_length, 1); + (char **)&key, &key_length, 1); value= memcached_fetch(ptr, NULL, NULL, value_length, flags, error); @@ -95,8 +97,10 @@ memcached_return memcached_mget(memcached_st *ptr, } memcached_return memcached_mget_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char **keys, size_t *key_length, + const char *master_key, + size_t master_key_length, + char **keys, + size_t *key_length, unsigned int number_of_keys) { unsigned int x; diff --git a/libmemcached/memcached_get.h b/libmemcached/memcached_get.h new file mode 100644 index 00000000..5535f345 --- /dev/null +++ b/libmemcached/memcached_get.h @@ -0,0 +1,56 @@ +/* + * Summary: Get functions for libmemcached + * + * Copy: See Copyright for the status of this software. + * + * Author: Brian Aker + */ + +#ifndef __MEMCACHED_GET_H__ +#define __MEMCACHED_GET_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Public defines */ +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, + char **keys, size_t *key_length, + unsigned int 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, + char **keys, + size_t *key_length, + unsigned int 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_result_st *memcached_fetch_result(memcached_st *ptr, + memcached_result_st *result, + memcached_return *error); + + + +#ifdef __cplusplus +} +#endif + +#endif /* __MEMCACHED_GET_H__ */ diff --git a/libmemcached/memcached_hash.c b/libmemcached/memcached_hash.c index e2454ac9..cca7b5a4 100644 --- a/libmemcached/memcached_hash.c +++ b/libmemcached/memcached_hash.c @@ -8,10 +8,10 @@ static uint32_t FNV_32_INIT= 2166136261UL; static uint32_t FNV_32_PRIME= 16777619; /* Prototypes */ -static uint32_t internal_generate_hash(char *key, size_t key_length); -static uint32_t internal_generate_md5(char *key, size_t key_length); +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 generate_hash(memcached_st *ptr, char *key, size_t key_length) +uint32_t generate_hash(memcached_st *ptr, const char *key, size_t key_length) { uint32_t hash= 1; /* Just here to remove compile warning */ uint32_t x= 0; @@ -161,7 +161,7 @@ unsigned int dispatch_host(memcached_st *ptr, uint32_t hash) One day make this public, and have it return the actual memcached_server_st to the calling application. */ -uint32_t memcached_generate_hash(memcached_st *ptr, char *key, size_t key_length) +uint32_t memcached_generate_hash(memcached_st *ptr, const char *key, size_t key_length) { uint32_t hash= 1; /* Just here to remove compile warning */ @@ -176,9 +176,9 @@ uint32_t memcached_generate_hash(memcached_st *ptr, char *key, size_t key_length return dispatch_host(ptr, hash); } -static uint32_t internal_generate_hash(char *key, size_t key_length) +static uint32_t internal_generate_hash(const char *key, size_t key_length) { - char *ptr= key; + const char *ptr= key; uint32_t value= 0; while (--key_length) @@ -194,7 +194,7 @@ static uint32_t internal_generate_hash(char *key, size_t key_length) return value == 0 ? 1 : value; } -static uint32_t internal_generate_md5(char *key, size_t key_length) +static uint32_t internal_generate_md5(const char *key, size_t key_length) { unsigned char results[16]; diff --git a/libmemcached/memcached_io.c b/libmemcached/memcached_io.c index b9261f3d..38544102 100644 --- a/libmemcached/memcached_io.c +++ b/libmemcached/memcached_io.c @@ -158,10 +158,10 @@ ssize_t memcached_io_read(memcached_server_st *ptr, } ssize_t memcached_io_write(memcached_server_st *ptr, - char *buffer, size_t length, char with_flush) + const char *buffer, size_t length, char with_flush) { size_t original_length; - char* buffer_ptr; + const char* buffer_ptr; original_length= length; buffer_ptr= buffer; diff --git a/libmemcached/memcached_io.h b/libmemcached/memcached_io.h index 30ac18b2..887f5200 100644 --- a/libmemcached/memcached_io.h +++ b/libmemcached/memcached_io.h @@ -2,7 +2,7 @@ #include ssize_t memcached_io_write(memcached_server_st *ptr, - char *buffer, size_t length, char with_flush); + const char *buffer, size_t length, char with_flush); void memcached_io_reset(memcached_server_st *ptr); ssize_t memcached_io_read(memcached_server_st *ptr, char *buffer, size_t length); diff --git a/libmemcached/memcached_stats.c b/libmemcached/memcached_stats.c index 3abc9b19..cf3adc12 100644 --- a/libmemcached/memcached_stats.c +++ b/libmemcached/memcached_stats.c @@ -192,7 +192,7 @@ char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *stat, else if (!memcmp("bytes_written", key, strlen("bytes_written"))) length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)stat->bytes_written); else if (!memcmp("limit_maxbytes", key, strlen("limit_maxbytes"))) - length= snprintf(buffer, SMALL_STRING_LEN,"%llu", stat->limit_maxbytes); + length= snprintf(buffer, SMALL_STRING_LEN,"%llu", (unsigned long long)stat->limit_maxbytes); else if (!memcmp("threads", key, strlen("threads"))) length= snprintf(buffer, SMALL_STRING_LEN,"%u", stat->threads); else diff --git a/libmemcached/memcached_storage.c b/libmemcached/memcached_storage.c index 30afd263..8f04c528 100644 --- a/libmemcached/memcached_storage.c +++ b/libmemcached/memcached_storage.c @@ -42,9 +42,9 @@ static char *storage_op_string(memcached_storage_action verb) } static inline memcached_return memcached_send(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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, @@ -65,7 +65,7 @@ static inline memcached_return memcached_send(memcached_st *ptr, unlikely (ptr->number_of_hosts == 0) return MEMCACHED_NO_SERVERS; - if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test(&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED)) + if ((ptr->flags & MEM_VERIFY_KEY) && (memcachd_key_test((char **)&key, &key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED)) return MEMCACHED_BAD_KEY_PROVIDED; server_key= memcached_generate_hash(ptr, master_key, master_key_length); @@ -125,8 +125,8 @@ error: return rc; } -memcached_return memcached_set(memcached_st *ptr, char *key, size_t key_length, - char *value, size_t value_length, +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) { @@ -140,8 +140,8 @@ memcached_return memcached_set(memcached_st *ptr, char *key, size_t key_length, } memcached_return memcached_add(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags) { @@ -155,8 +155,8 @@ memcached_return memcached_add(memcached_st *ptr, } memcached_return memcached_replace(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags) { @@ -170,8 +170,8 @@ memcached_return memcached_replace(memcached_st *ptr, } memcached_return memcached_prepend(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags) { @@ -183,8 +183,8 @@ memcached_return memcached_prepend(memcached_st *ptr, } memcached_return memcached_append(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags) { @@ -196,8 +196,8 @@ memcached_return memcached_append(memcached_st *ptr, } memcached_return memcached_cas(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags, uint64_t cas) @@ -210,9 +210,9 @@ memcached_return memcached_cas(memcached_st *ptr, } memcached_return memcached_set_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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) { @@ -226,9 +226,9 @@ memcached_return memcached_set_by_key(memcached_st *ptr, } memcached_return memcached_add_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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) { @@ -242,9 +242,9 @@ memcached_return memcached_add_by_key(memcached_st *ptr, } memcached_return memcached_replace_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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) { @@ -258,9 +258,9 @@ memcached_return memcached_replace_by_key(memcached_st *ptr, } memcached_return memcached_prepend_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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) { @@ -272,9 +272,9 @@ memcached_return memcached_prepend_by_key(memcached_st *ptr, } memcached_return memcached_append_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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) { @@ -286,9 +286,9 @@ memcached_return memcached_append_by_key(memcached_st *ptr, } memcached_return memcached_cas_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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) diff --git a/libmemcached/memcached_storage.h b/libmemcached/memcached_storage.h index 98211f6b..25adc983 100644 --- a/libmemcached/memcached_storage.h +++ b/libmemcached/memcached_storage.h @@ -14,74 +14,74 @@ extern "C" { #endif /* All of the functions for adding data to the server */ -memcached_return memcached_set(memcached_st *ptr, char *key, size_t key_length, - char *value, size_t value_length, +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 memcached_add(memcached_st *ptr, char *key, size_t key_length, - char *value, size_t value_length, +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 memcached_replace(memcached_st *ptr, char *key, size_t key_length, - char *value, size_t value_length, +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 memcached_append(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return memcached_prepend(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_length, + const char *key, size_t key_length, + const char *value, size_t value_length, time_t expiration, uint32_t flags); memcached_return memcached_cas(memcached_st *ptr, - char *key, size_t key_length, - char *value, size_t value_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 memcached_set_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_add_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_replace_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_prepend_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_append_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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 memcached_cas_by_key(memcached_st *ptr, - char *master_key, size_t master_key_length, - char *key, size_t key_length, - char *value, size_t value_length, + 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); diff --git a/libmemcached/memcached_types.h b/libmemcached/memcached_types.h index 20837af9..f00f9afa 100644 --- a/libmemcached/memcached_types.h +++ b/libmemcached/memcached_types.h @@ -27,10 +27,10 @@ typedef void *(*memcached_realloc_function)(memcached_st *ptr, void *mem, const 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, - char *key, size_t key_length, + const char *key, size_t key_length, memcached_result_st *result); typedef memcached_return (*memcached_trigger_delete_key)(memcached_st *ptr, - char *key, size_t key_length); + const char *key, size_t key_length); #ifdef __cplusplus } diff --git a/libmemcached/murmur_hash.c b/libmemcached/murmur_hash.c index 7cfcaa9e..7275aa34 100644 --- a/libmemcached/murmur_hash.c +++ b/libmemcached/murmur_hash.c @@ -6,7 +6,7 @@ #define MIX(h,k,m) { k *= m; k ^= k >> r; k *= m; h *= m; h ^= k; } -uint32_t murmur_hash(char *key, size_t length) +uint32_t murmur_hash(const char *key, size_t length) { const uint32_t m= 0x5bd1e995; const int r= 16;