Bug #447237: const-correctness in interface
authorTrond Norbye <trond.norbye@sun.com>
Wed, 14 Oct 2009 10:31:33 +0000 (12:31 +0200)
committerTrond Norbye <trond.norbye@sun.com>
Wed, 14 Oct 2009 10:31:33 +0000 (12:31 +0200)
docs/memcached_get.pod
libmemcached/common.h
libmemcached/memcached_get.c
libmemcached/memcached_get.h
libmemcached/memcached_key.c

index 4c80fb3e4e73db30ba6cf36f07c28db4af7ca7ab..5dde1edcbc0ab8cf66e5e06d6343a280c0a37606 100644 (file)
@@ -23,7 +23,8 @@ C Client Library for memcached (libmemcached, -lmemcached)
 
   memcached_return
   memcached_mget (memcached_st *ptr, 
-                  char **keys, size_t *key_length, 
+                  const char * const *keys, 
+                  const size_t *key_length, 
                   size_t number_of_keys);
   char *
   memcached_get_by_key(memcached_st *ptr, 
@@ -36,7 +37,8 @@ C Client Library for memcached (libmemcached, -lmemcached)
   memcached_return 
   memcached_mget_by_key(memcached_st *ptr, 
                         const char *master_key, size_t master_key_length,
-                        char **keys, size_t *key_length, 
+                        const char * const *keys, 
+                        const size_t *key_length, 
                         size_t number_of_keys);
 
   char *memcached_fetch (memcached_st *ptr,
@@ -56,8 +58,8 @@ C Client Library for memcached (libmemcached, -lmemcached)
   memcached_mget_execute(memcached_st *ptr,
                          const char *master_key,
                          size_t master_key_length,
-                         const char **keys,
-                         size_t *key_length,
+                         const char * const *keys,
+                         const size_t *key_length,
                          size_t number_of_keys,
                          memcached_execute_function *callback,
                          void *context,
index 96b834632ccfaefa23d3ce5f1bd97acf1e84703d..30fc4e12a9fbfb6203075b55b948dcd4af523b3d 100644 (file)
@@ -136,7 +136,8 @@ LIBMEMCACHED_LOCAL
 void server_list_free(memcached_st *ptr, memcached_server_st *servers);
 
 LIBMEMCACHED_LOCAL
-memcached_return memcached_key_test(const char **keys, size_t *key_length,
+memcached_return memcached_key_test(const char * const *keys, 
+                                    const size_t *key_length,
                                     size_t number_of_keys);
 
 
index 53c76f4bd67279599c5d6296098a8f970582d683..90cf456f57bd4d00640d8ab2dfce77e1f7f28c75 100644 (file)
@@ -15,12 +15,12 @@ char *memcached_get(memcached_st *ptr, const char *key,
 }
 
 static memcached_return memcached_mget_by_key_real(memcached_st *ptr, 
-                                       const char *master_key, 
-                                       size_t master_key_length,
-                                       const char **keys, 
-                                       size_t *key_length, 
-                                       size_t number_of_keys,
-                                      bool mget_mode);
+                                                   const char *master_key, 
+                                                   size_t master_key_length,
+                                                   const char * const *keys, 
+                                                   const size_t *key_length, 
+                                                   size_t number_of_keys,
+                                                   bool mget_mode);
 
 char *memcached_get_by_key(memcached_st *ptr, 
                            const char *master_key, 
@@ -42,10 +42,9 @@ char *memcached_get_by_key(memcached_st *ptr,
   }
 
   /* Request the key */
-  *error= memcached_mget_by_key_real(ptr, 
-                                master_key, 
-                                master_key_length, 
-                                (const char **)&key, &key_length, 1, false);
+  *error= memcached_mget_by_key_real(ptr, master_key, master_key_length, 
+                                     (const char * const *)&key, 
+                                     &key_length, 1, false);
 
   value= memcached_fetch(ptr, NULL, NULL, 
                          value_length, flags, error);
@@ -110,7 +109,8 @@ char *memcached_get_by_key(memcached_st *ptr,
 }
 
 memcached_return memcached_mget(memcached_st *ptr, 
-                                const char **keys, size_t *key_length, 
+                                const char * const *keys, 
+                                const size_t *key_length, 
                                 size_t number_of_keys)
 {
   return memcached_mget_by_key(ptr, NULL, 0, keys, key_length, number_of_keys);
@@ -119,17 +119,18 @@ memcached_return memcached_mget(memcached_st *ptr,
 static memcached_return binary_mget_by_key(memcached_st *ptr,
                                            unsigned int master_server_key,
                                            bool is_master_key_set,
-                                           const char **keys, size_t *key_length,
+                                           const char * const *keys, 
+                                           const size_t *key_length,
                                            size_t number_of_keys,
                                           bool mget_mode);
 
 static memcached_return memcached_mget_by_key_real(memcached_st *ptr, 
-                                       const char *master_key, 
-                                       size_t master_key_length,
-                                       const char **keys, 
-                                       size_t *key_length, 
-                                       size_t number_of_keys,
-                                      bool mget_mode)
+                                                   const char *master_key, 
+                                                   size_t master_key_length,
+                                                   const char * const *keys, 
+                                                   const size_t *key_length, 
+                                                   size_t number_of_keys,
+                                                   bool mget_mode)
 {
   unsigned int x;
   memcached_return rc= MEMCACHED_NOTFOUND;
@@ -155,7 +156,7 @@ static memcached_return memcached_mget_by_key_real(memcached_st *ptr,
 
   if (master_key && master_key_length)
   {
-    if ((ptr->flags & MEM_VERIFY_KEY) && (memcached_key_test((const char **)&master_key, &master_key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
+    if ((ptr->flags & MEM_VERIFY_KEY) && (memcached_key_test((const char * const *)&master_key, &master_key_length, 1) == MEMCACHED_BAD_KEY_PROVIDED))
       return MEMCACHED_BAD_KEY_PROVIDED;
     master_server_key= memcached_generate_hash(ptr, master_key, master_key_length);
     is_master_key_set= true;
@@ -269,8 +270,8 @@ static memcached_return memcached_mget_by_key_real(memcached_st *ptr,
 memcached_return memcached_mget_by_key(memcached_st *ptr, 
                                        const char *master_key, 
                                        size_t master_key_length,
-                                       const char **keys, 
-                                       size_t *key_length, 
+                                       const char * const *keys, 
+                                       const size_t *key_length, 
                                        size_t number_of_keys)
 {
   return memcached_mget_by_key_real(ptr, master_key, master_key_length, keys, 
@@ -280,8 +281,8 @@ memcached_return memcached_mget_by_key(memcached_st *ptr,
 memcached_return memcached_mget_execute(memcached_st *ptr,
                                         const char *master_key,
                                         size_t master_key_length,
-                                        const char **keys,
-                                        size_t *key_length,
+                                        const char * const *keys,
+                                        const size_t *key_length,
                                         size_t number_of_keys,
                                         memcached_execute_function *callback,
                                         void *context,
@@ -308,7 +309,8 @@ memcached_return memcached_mget_execute(memcached_st *ptr,
 static memcached_return simple_binary_mget(memcached_st *ptr,
                                            unsigned int master_server_key,
                                            bool is_master_key_set,
-                                           const char **keys, size_t *key_length, 
+                                           const char * const *keys, 
+                                           const size_t *key_length, 
                                            size_t number_of_keys, bool mget_mode)
 {
   memcached_return rc= MEMCACHED_NOTFOUND;
@@ -410,9 +412,12 @@ static memcached_return simple_binary_mget(memcached_st *ptr,
 }
 
 static memcached_return replication_binary_mget(memcached_st *ptr,
-                                             uint32_t* hash, bool* dead_servers,
-                                             const char **keys, size_t *key_length,
-                                             size_t number_of_keys, bool mget_mode)
+                                                uint32_t* hash, 
+                                                bool* dead_servers,
+                                                const char *const *keys, 
+                                                const size_t *key_length,
+                                                size_t number_of_keys, 
+                                                bool mget_mode)
 {
   memcached_return rc= MEMCACHED_NOTFOUND;
   uint32_t x;
@@ -511,8 +516,10 @@ static memcached_return replication_binary_mget(memcached_st *ptr,
 static memcached_return binary_mget_by_key(memcached_st *ptr,
                                            unsigned int master_server_key,
                                            bool is_master_key_set,
-                                           const char **keys, size_t *key_length,
-                                           size_t number_of_keys, bool mget_mode)
+                                           const char * const *keys, 
+                                           const size_t *key_length,
+                                           size_t number_of_keys, 
+                                           bool mget_mode)
 {
   memcached_return rc;
 
index 6e10ad182bc030b742f79eb6035b58eb2ed5c5d0..11dd7fee82884923b33224375828a3a83ee3cc62 100644 (file)
@@ -23,7 +23,8 @@ char *memcached_get(memcached_st *ptr,
 
 LIBMEMCACHED_API
 memcached_return memcached_mget(memcached_st *ptr, 
-                                const char **keys, size_t *key_length, 
+                                const char * const *keys, 
+                                const size_t *key_length, 
                                 size_t number_of_keys);
 
 LIBMEMCACHED_API
@@ -38,8 +39,8 @@ LIBMEMCACHED_API
 memcached_return memcached_mget_by_key(memcached_st *ptr, 
                                        const char *master_key, size_t 
                                        master_key_length,
-                                       const char **keys, 
-                                       size_t *key_length, 
+                                       const char * const *keys, 
+                                       const size_t *key_length, 
                                        size_t number_of_keys);
 
 LIBMEMCACHED_API
@@ -57,8 +58,8 @@ LIBMEMCACHED_API
 memcached_return memcached_mget_execute(memcached_st *ptr,
                                         const char *master_key,
                                         size_t master_key_length,
-                                        const char **keys,
-                                        size_t *key_length,
+                                        const char * const *keys,
+                                        const size_t *key_length,
                                         size_t number_of_keys,
                                         memcached_execute_function *callback,
                                         void *context,
index c8a3a0eb4f5d59d325f88614adc7ce3dad099827..9aac1ebcfd24f0828b66e8d75ce1e5cd8f35716a 100644 (file)
@@ -1,6 +1,7 @@
 #include "common.h"
 
-memcached_return memcached_key_test(const char **keys, size_t *key_length, 
+memcached_return memcached_key_test(const char * const *keys, 
+                                    const size_t *key_length, 
                                     size_t number_of_keys)
 {
   uint32_t x;
@@ -14,8 +15,6 @@ memcached_return memcached_key_test(const char **keys, size_t *key_length,
     if (rc != MEMCACHED_SUCCESS)
       return rc;
     
-
-
     for (y= 0; y < *(key_length + x); y++)
     {
       if ((isgraph(keys[x][y])) == 0)