Small cleanup for loop.
[awesomized/libmemcached] / libmemcached / stats.c
index cf7f4d68355cc87fc668be0a0775c39407e04b0d..6378d89e0a2d087336c672b39a37f4890750cb1f 100644 (file)
@@ -219,7 +219,7 @@ char *memcached_stat_get_value(memcached_st *ptr, memcached_stat_st *memc_stat,
     return NULL;
   }
 
-  ret= ptr->call_malloc(ptr, (size_t) (length + 1));
+  ret= libmemcached_malloc(ptr, (size_t) (length + 1));
   memcpy(ret, buffer, (size_t) length);
   ret[length]= '\0';
 
@@ -357,7 +357,6 @@ error:
 
 memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error)
 {
-  uint32_t x;
   memcached_return_t rc;
   memcached_stat_st *stats;
 
@@ -367,31 +366,34 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
     return NULL;
   }
 
-  stats= ptr->call_calloc(ptr, memcached_server_count(ptr), sizeof(memcached_stat_st));
+  stats= libmemcached_calloc(ptr, memcached_server_count(ptr), sizeof(memcached_stat_st));
 
-  stats->root= ptr;
-
-  if (!stats)
+  if (! stats)
   {
     *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
     return NULL;
   }
 
   rc= MEMCACHED_SUCCESS;
-  for (x= 0; x < memcached_server_count(ptr); x++)
+  for (uint32_t x= 0; x < memcached_server_count(ptr); x++)
   {
     memcached_return_t temp_return;
     memcached_server_instance_st *instance;
+    memcached_stat_st *stat_instance;
+
+    stat_instance= stats + x;
+
+    stat_instance->root= ptr;
 
     instance= memcached_server_instance_fetch(ptr, x);
 
     if (ptr->flags.binary_protocol)
     {
-      temp_return= binary_stats_fetch(stats + x, args, instance);
+      temp_return= binary_stats_fetch(stat_instance, args, instance);
     }
     else
     {
-      temp_return= ascii_stats_fetch(stats + x, args, instance);
+      temp_return= ascii_stats_fetch(stat_instance, args, instance);
     }
 
     if (temp_return != MEMCACHED_SUCCESS)
@@ -435,16 +437,18 @@ memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char
   We make a copy of the keys since at some point in the not so distant future
   we will add support for "found" keys.
 */
-char ** memcached_stat_get_keys(memcached_st *ptr, memcached_stat_st *memc_stat,
+char ** memcached_stat_get_keys(memcached_st *ptr,
+                                memcached_stat_st *memc_stat,
                                 memcached_return_t *error)
 {
-  (void) memc_stat;
   char **list;
   size_t length= sizeof(memcached_stat_keys);
 
-  list= ptr->call_malloc(ptr, length);
+  (void)memc_stat;
+
+  list= libmemcached_malloc(ptr, length);
 
-  if (!list)
+  if (! list)
   {
     *error= MEMCACHED_MEMORY_ALLOCATION_FAILURE;
     return NULL;
@@ -467,11 +471,11 @@ void memcached_stat_free(memcached_st *ptr, memcached_stat_st *memc_stat)
 
   if (memc_stat->root)
   {
-    memc_stat->root->call_free(ptr, memc_stat);
+    libmemcached_free(memc_stat->root, memc_stat);
   }
   else if (ptr)
   {
-    ptr->call_free(ptr, memc_stat);
+    libmemcached_free(ptr, memc_stat);
   }
   else
   {