Some patches for cmemcache

FreeWizard freewizard at gmail.com
Mon May 28 11:33:38 UTC 2007


cmemcache is New (experimental) C (and PHP) memcached library by Alex Stapleton
http://lists.danga.com/pipermail/memcached/2007-April/004070.html

Since these patches are very short, so i didn't attach them as files.

1. Compile under X86_64
Index: cmemcache.c
===================================================================
--- cmemcache.c (revision 19)
+++ cmemcache.c (working copy)
@@ -489,7 +489,7 @@
                  free(line);
                  evbuffer_drain_all(server->await_buf);

-                 if(*dest != ULONG_MAX) {
+                 if(*dest != UINT_MAX) {
                           return 0;
                  } else {
                           if(errno == EINVAL || errno == ERANGE) {
@@ -515,14 +515,14 @@
                  if(strcmp(line, "NOT_FOUND") != 0) {
                           *dest = strtoul(line, 0, 10);
                  } else {
-                          *dest = ULONG_MAX;
+                          *dest = UINT_MAX;
                           not_found = 1;
                  }

                  free(line);
                  evbuffer_drain_all(server->await_buf);

-                 if(*dest != ULONG_MAX && not_found == 0) {
+                 if(*dest != UINT_MAX && not_found == 0) {
                           return 0;
                  } else {
                           if(errno == EINVAL || errno == ERANGE ||
not_found == 1) {

2. C99 compatible (required with GCC4)
Index: php_cmemcache/php_cmemcache.c
===================================================================
--- php_cmemcache/php_cmemcache.c       (revision 19)
+++ php_cmemcache/php_cmemcache.c       (working copy)
@@ -243,7 +243,8 @@
         // get the results and process them into a PHP array
         memc_get_results_t** rs = memc_get_keys(pool, keys, keys_count);

-        for(int i=0; i < keys_count; ++i) {
+        int i;
+        for(i=0; i < keys_count; ++i) {
                  free(keys[i]);
         }
Index: cmemcache.h
===================================================================
--- cmemcache.h (revision 19)
+++ cmemcache.h (working copy)
@@ -30,7 +30,7 @@
 #define evbuffer_drain_all(buf) evbuffer_drain(buf, EVBUFFER_LENGTH(buf))

 #define MEMC_NEXT_RESULT(r) r->next
-#define MEMC_FOREACH_RESULTS(rs) if(rs) for(memc_get_result_t* result
= (*rs)->head; result; result = MEMC_NEXT_RESULT(result))
+#define MEMC_FOREACH_RESULTS(rs) memc_get_result_t* result; if(rs)
for(result = (*rs)->head; result; result = MEMC_NEXT_RESULT(result))

 #define SERVER_UDP_DOWN 1
 #define SERVER_TCP_DOWN 2

3. fix typo
Index: php_cmemcache/test_cmem.php
===================================================================
--- php_cmemcache/test_cmem.php (revision 19)
+++ php_cmemcache/test_cmem.php (working copy)
@@ -34,7 +34,7 @@

 $get_s = mt();
 $get = memc_get_keys($pool, $key_arr);
-var_dump($det);
+var_dump($get);
 $get_e = mt();
 ptiming("multi get", $get_s, $get_e, count($key_arr)/1000);


More information about the memcached mailing list