X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_hosts.c;h=abb1ce036088fc6d56fd003949e67988da5012c5;hb=db4741c1f65edf1323e4aa0879c4589244af1971;hp=30c8f954c697de6e8502558edb65a880f941d28c;hpb=defb3c5e4b25d32435b21a99eb85c016d0b1adc9;p=m6w6%2Flibmemcached diff --git a/libmemcached/memcached_hosts.c b/libmemcached/memcached_hosts.c index 30c8f954..abb1ce03 100644 --- a/libmemcached/memcached_hosts.c +++ b/libmemcached/memcached_hosts.c @@ -117,14 +117,19 @@ memcached_return update_continuum(memcached_st *ptr) 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 == 0) + return MEMCACHED_SUCCESS; + 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); + 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); + 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;