Merge in additional documentation updates.
[awesomized/libmemcached] / libmemcached / hosts.c
index d95dbcfff2fb0f55333afa58f368e01ecd33854d..93f830a7cafa5a32f195a25fa27f2e723abbaa5b 100644 (file)
@@ -226,8 +226,8 @@ static memcached_return_t update_continuum(memcached_st *ptr)
           for (uint32_t x= 0; x < pointer_per_hash; x++)
           {
             uint32_t value= ketama_server_hash(sort_host, (size_t)sort_host_length, x);
-             ptr->ketama.continuum[continuum_index].index= host_index;
-             ptr->ketama.continuum[continuum_index++].value= value;
+            ptr->ketama.continuum[continuum_index].index= host_index;
+            ptr->ketama.continuum[continuum_index++].value= value;
           }
         }
         else
@@ -274,9 +274,9 @@ static memcached_return_t update_continuum(memcached_st *ptr)
         {
           for (uint32_t x = 0; x < pointer_per_hash; x++)
           {
-             uint32_t value= ketama_server_hash(sort_host, (size_t)sort_host_length, x);
-             ptr->ketama.continuum[continuum_index].index= host_index;
-             ptr->ketama.continuum[continuum_index++].value= value;
+            uint32_t value= ketama_server_hash(sort_host, (size_t)sort_host_length, x);
+            ptr->ketama.continuum[continuum_index].index= host_index;
+            ptr->ketama.continuum[continuum_index++].value= value;
           }
         }
         else
@@ -339,10 +339,15 @@ memcached_return_t memcached_server_push(memcached_st *ptr, const memcached_serv
     WATCHPOINT_ASSERT(list[x].hostname[0] != 0);
 
     instance= memcached_server_instance_fetch(ptr, memcached_server_count(ptr));
+    WATCHPOINT_ASSERT(instance);
 
     /* TODO check return type */
-    (void)memcached_server_create_with(ptr, instance, list[x].hostname,
-                                       list[x].port, list[x].weight, list[x].type);
+    instance= memcached_server_create_with(ptr, instance, list[x].hostname,
+                                           list[x].port, list[x].weight, list[x].type);
+    if (! instance)
+    {
+      return memcached_set_error(ptr, MEMCACHED_MEMORY_ALLOCATION_FAILURE, NULL);
+    }
     ptr->number_of_hosts++;
   }