-#define MEMCACHED_WHEEL_SIZE 1024
-#define MEMCACHED_STRIDE 4
-static memcached_return rebalance_wheel(memcached_st *ptr)
-{
- unsigned int x;
- unsigned int y;
- unsigned int latch;
-
- if (ptr->number_of_hosts > ptr->wheel_count)
- {
- uint32_t *new_ptr;
-
- if (ptr->call_realloc)
- new_ptr= (uint32_t *)ptr->call_realloc(ptr, ptr->wheel, sizeof(uint32_t) * (ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION) * MEMCACHED_STRIDE);
- else
- new_ptr= (uint32_t *)realloc(ptr->wheel, sizeof(uint32_t) * (ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION) * MEMCACHED_STRIDE);
-
- if (new_ptr == 0)
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
-
- ptr->wheel= new_ptr;
- ptr->wheel_count= ptr->number_of_hosts + MEMCACHED_CONTINUUM_ADDITION;
- }
-
- /* Seed the Wheel */
- memset(ptr->wheel, 0, sizeof(uint32_t) * MEMCACHED_STRIDE * ptr->wheel_count);
-
- for (latch= y= x= 0; x < MEMCACHED_STRIDE * ptr->wheel_count; x++, latch++)
- {
- if (latch == MEMCACHED_STRIDE)
- {
- y++;
- if (y == ptr->number_of_hosts)
- y= 0;
- latch= 0;
- }
-
- ptr->wheel[x]= y;
- }
-
- return MEMCACHED_SUCCESS;
-}
-