+ memcached_server_st *list;
+ uint32_t pointer_counter= 0;
+ uint32_t pointer_per_server= MEMCACHED_POINTS_PER_SERVER;
+ uint32_t pointer_per_hash= 1;
+ uint64_t total_weight= 0;
+ uint32_t is_ketama_weighted= 0;
+ uint32_t points_per_server= 0;
+
+ is_ketama_weighted= memcached_behavior_get(ptr, MEMCACHED_BEHAVIOR_KETAMA_WEIGHTED);
+ points_per_server= is_ketama_weighted ? MEMCACHED_POINTS_PER_SERVER_KETAMA : MEMCACHED_POINTS_PER_SERVER;
+
+ if (ptr->number_of_hosts > ptr->continuum_count)
+ {
+ memcached_continuum_item_st *new_ptr;
+
+ if (ptr->call_realloc)
+ new_ptr= (memcached_continuum_item_st *)ptr->call_realloc(ptr, ptr->continuum, sizeof(memcached_continuum_item_st) * (ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION) * points_per_server);
+ else
+ new_ptr= (memcached_continuum_item_st *)realloc(ptr->continuum, sizeof(memcached_continuum_item_st) * (ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION) * points_per_server);
+
+ if (new_ptr == 0)
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+
+ ptr->continuum= new_ptr;
+ ptr->continuum_count= ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION;
+ }
+
+ list = ptr->hosts;
+
+ if (is_ketama_weighted)
+ {
+ for (host_index = 0; host_index < ptr->number_of_hosts; ++host_index)
+ {
+ if (list[host_index].weight == 0)
+ {
+ list[host_index].weight = 1;
+ }
+ total_weight += list[host_index].weight;
+ }
+ }