+ memcached_continuum_item_st *new_ptr;
+
+ new_ptr= ptr->call_realloc(ptr, ptr->continuum,
+ sizeof(memcached_continuum_item_st) * (live_servers + MEMCACHED_CONTINUUM_ADDITION) * points_per_server);
+
+ if (new_ptr == 0)
+ return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+
+ ptr->continuum= new_ptr;
+ ptr->continuum_count= live_servers + MEMCACHED_CONTINUUM_ADDITION;
+ }
+
+ 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;
+ }
+ if (!is_auto_ejecting || list[host_index].next_retry <= now.tv_sec)
+ total_weight += list[host_index].weight;
+ }
+ }
+
+ for (host_index = 0; host_index < ptr->number_of_hosts; ++host_index)
+ {
+ if (is_auto_ejecting && list[host_index].next_retry > now.tv_sec)
+ continue;
+
+ if (is_ketama_weighted)
+ {
+ float pct = (float)list[host_index].weight / (float)total_weight;
+ pointer_per_server= (uint32_t) ((floorf((float) (pct * MEMCACHED_POINTS_PER_SERVER_KETAMA / 4 * (float)live_servers + 0.0000000001))) * 4);
+ pointer_per_hash= 4;
+#ifdef DEBUG
+ printf("ketama_weighted:%s|%d|%llu|%u\n",
+ list[host_index].hostname,
+ list[host_index].port,
+ (unsigned long long)list[host_index].weight,
+ pointer_per_server);
+#endif
+ }
+ for (pointer_index= 1;
+ pointer_index <= pointer_per_server / pointer_per_hash;
+ ++pointer_index)