Fixed all key methods to now take const char * (all previous code will work
authorBrian Aker <brian@tangent.org>
Tue, 20 May 2008 23:05:04 +0000 (16:05 -0700)
committerBrian Aker <brian@tangent.org>
Tue, 20 May 2008 23:05:04 +0000 (16:05 -0700)
just fine).

23 files changed:
ChangeLog
docs/memcached_auto.pod
docs/memcached_delete.pod
docs/memcached_get.pod
docs/memcached_set.pod
libmemcached/Makefile.am
libmemcached/common.h
libmemcached/hsieh_hash.c
libmemcached/md5.c
libmemcached/memcached.h
libmemcached/memcached_auto.c
libmemcached/memcached_delete.c
libmemcached/memcached_do.c
libmemcached/memcached_get.c
libmemcached/memcached_get.h [new file with mode: 0644]
libmemcached/memcached_hash.c
libmemcached/memcached_io.c
libmemcached/memcached_io.h
libmemcached/memcached_stats.c
libmemcached/memcached_storage.c
libmemcached/memcached_storage.h
libmemcached/memcached_types.h
libmemcached/murmur_hash.c

index 78af7501feef7485c784065d8ff74d26e746fe51..f85b6295d58dac1c6f17a3cc3bac435e6bd7afef 100644 (file)
--- 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.
index 27332e93ee7fe41ef028450130cc9862eaedf3e1..df0a8b58b4352dc7da9020e96bc2684d95177b40 100755 (executable)
@@ -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);
 
index 18fec84b4cb80c754577a1528e236abe122e1e44..41a55df976d6e08101ba444633027ef1946d015e 100755 (executable)
@@ -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
index 5557e7c31c151404bb25d14a520937b6b4a27aa8..df0ac7799ee985f3e85e37edbc89e2c3c9cfde9d 100755 (executable)
@@ -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);
index 6e962d382ea6522037fb6cc20d67139e96d5e8ff..5e7ac18626e2ef8bccc660c86b2a5182bc8cdc2e 100755 (executable)
@@ -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);
index 18cdf23aac2ebf3dfed0326d2470c2ce43a299a7..550b4890fc490b4148e2b8cddf892db662517283 100644 (file)
@@ -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 \
index b240619669e27de4dc779ed30e189fff98d472cf..ad6ccd7de6f5821b3a80e263125d4a250652ef56 100644 (file)
@@ -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__ */
index 9f42a94d02da91a6e62c2f8be1d1b762c3eb2892..e6c23cd97a64ba6783ff253b735b6ab24b404286 100644 (file)
@@ -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;
index 61f8d692898123085deb7f56e37413078423981b..ef43035a4defe562bb30bbed592aeac752f5d5a1 100644 (file)
@@ -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;
   }
index 3a1def4845086c06f57fcc57485762aebbf66fa5..b907809da0fa5fe65312d1e496a8ae9484a9ed46 100644 (file)
@@ -19,6 +19,7 @@
 #include <libmemcached/memcached_constants.h>
 #include <libmemcached/memcached_types.h>
 #include <libmemcached/memcached_watchpoint.h>
+#include <libmemcached/memcached_get.h>
 #include <libmemcached/memcached_server.h>
 #include <libmemcached/memcached_string.h>
 #include <libmemcached/memcached_result.h>
@@ -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, 
index a607ed66e23298881c2ee5bfd6d3ea429aafbb62..bc6adc0f23f1f0f21524c89f784fc6a3a340846e 100644 (file)
@@ -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)
 {
index 37a28add0c18dcff7e8143ce3ca14962f1f2e787..5df976ad18919cccb16cab219fd8b545b14f68ef 100644 (file)
@@ -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;
index c4bf574f641d8a28d36ce649db884bc20d913c74..671b9fa3f3b809f2a8850bdd47c699b53fca0654 100644 (file)
@@ -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;
index 852e90dd3004b6920cc4bf75efa81ddd0525159c..a2f7716d485d3e190b694899ef8074a487229c92 100644 (file)
@@ -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 (file)
index 0000000..5535f34
--- /dev/null
@@ -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__ */
index e2454ac99f068f1aa16b9a29bf8749c8004f2aec..cca7b5a40ab7e3ec3c6457a7cc0dda4e6c5fbafa 100644 (file)
@@ -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];
 
index b9261f3d9bc4ef27540f5799e702a538032aca31..38544102bcc54765101b25e2beb68e4390db639d 100644 (file)
@@ -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;
index 30ac18b2f448fb28a557ce3489cd9dfa45ffd734..887f520049e172e9f950e5f627075db864bf575c 100644 (file)
@@ -2,7 +2,7 @@
 #include <memcached.h>
 
 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);
index 3abc9b195e5391949f9111b93c9736eea6df12c0..cf3adc12dfc6e2ff296248ba52cd665309b56490 100644 (file)
@@ -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
index 30afd2634fc5a9406844b349b83443d1a29a6719..8f04c528e24ca24e4c6bfcfc6a0d707802c30b50 100644 (file)
@@ -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)
index 98211f6baf8cc85f0a5d5439e9ec8d7b00a27526..25adc983431b54521111d2e781d1813415a4ca5f 100644 (file)
@@ -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);
index 20837af94dbf9b890972be4742591e225ed61d75..f00f9afa396b0d52318e8a73185bb0856e868232 100644 (file)
@@ -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
 }
index 7cfcaa9eba087559de5c2d371f85bec615c6c460..7275aa348e253f286c5aac52a18b5cf9ebfbadb3 100644 (file)
@@ -6,7 +6,7 @@
 \r
 #define MIX(h,k,m) { k *= m; k ^= k >> r; k *= m; h *= m; h ^= k; }\r
 \r
-uint32_t murmur_hash(char *key, size_t length)\r
+uint32_t murmur_hash(const char *key, size_t length)\r
 {\r
   const uint32_t m= 0x5bd1e995;\r
   const int r= 16;\r