First pass on updating docs.
[awesomized/libmemcached] / libmemcached / stats.c
index 5a37dfd9130fdd528e0481e6c404b9c730b90e04..45b530e491cbfab745576ec6c34f5bd742a6aecf 100644 (file)
@@ -400,21 +400,22 @@ error:
     return rc;
 }
 
-memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_return_t *error)
+memcached_stat_st *memcached_stat(memcached_st *self, char *args, memcached_return_t *error)
 {
   memcached_return_t rc;
   memcached_stat_st *stats;
 
-  if (! ptr)
+  if ((rc= initialize_query(self)) != MEMCACHED_SUCCESS)
   {
-    WATCHPOINT_ASSERT(memc_ptr);
+    if (error)
+      *error= rc;
+
     return NULL;
   }
 
   WATCHPOINT_ASSERT(error);
 
-
-  unlikely (ptr->flags.use_udp)
+  unlikely (self->flags.use_udp)
   {
     if (error)
       *error= MEMCACHED_NOT_SUPPORTED;
@@ -422,7 +423,7 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
     return NULL;
   }
 
-  stats= libmemcached_calloc(ptr, memcached_server_count(ptr), sizeof(memcached_stat_st));
+  stats= libmemcached_calloc(self, memcached_server_count(self), sizeof(memcached_stat_st));
 
   if (! stats)
   {
@@ -432,8 +433,9 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
     return NULL;
   }
 
+  WATCHPOINT_ASSERT(rc == MEMCACHED_SUCCESS);
   rc= MEMCACHED_SUCCESS;
-  for (uint32_t x= 0; x < memcached_server_count(ptr); x++)
+  for (uint32_t x= 0; x < memcached_server_count(self); x++)
   {
     memcached_return_t temp_return;
     memcached_server_write_instance_st instance;
@@ -441,11 +443,11 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
 
     stat_instance= stats + x;
 
-    stat_instance->root= ptr;
+    stat_instance->root= self;
 
-    instance= memcached_server_instance_fetch(ptr, x);
+    instance= memcached_server_instance_fetch(self, x);
 
-    if (ptr->flags.binary_protocol)
+    if (self->flags.binary_protocol)
     {
       temp_return= binary_stats_fetch(stat_instance, args, instance, NULL);
     }
@@ -467,7 +469,6 @@ memcached_stat_st *memcached_stat(memcached_st *ptr, char *args, memcached_retur
 memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char *args,
                                              const char *hostname, in_port_t port)
 {
-  memcached_return_t rc;
   memcached_st memc;
   memcached_st *memc_ptr;
   memcached_server_write_instance_st instance;
@@ -475,10 +476,17 @@ memcached_return_t memcached_stat_servername(memcached_stat_st *memc_stat, char
   memset(memc_stat, 0, sizeof(memcached_stat_st));
 
   memc_ptr= memcached_create(&memc);
-  WATCHPOINT_ASSERT(memc_ptr);
+  if (! memc_ptr)
+    return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
 
   memcached_server_add(&memc, hostname, port);
 
+  memcached_return_t rc;
+  if ((rc= initialize_query(memc_ptr)) != MEMCACHED_SUCCESS)
+  {
+    return rc;
+  }
+
   instance= memcached_server_instance_fetch(memc_ptr, 0);
 
   if (memc.flags.binary_protocol)