const char *hostname, unsigned int port, uint32_t weight,
memcached_connection type)
{
- memset(host, 0, sizeof(memcached_server_st));
strncpy(host->hostname, hostname, MEMCACHED_MAX_HOST_LENGTH - 1);
host->root= ptr ? ptr : NULL;
host->port= port;
for (x= 0, index= 0; x < ptr->number_of_hosts; x++)
{
- if (strncmp(list[x].hostname, st_ptr->hostname, MEMCACHED_MAX_HOST_LENGTH)!=0 || list[x].port != st_ptr->port)
+ if (strncmp(list[x].hostname, st_ptr->hostname, MEMCACHED_MAX_HOST_LENGTH) != 0 || list[x].port != st_ptr->port)
{
- memcpy(list+index, list+x, sizeof(memcached_server_st));
+ if (index != x)
+ memcpy(list+index, list+x, sizeof(memcached_server_st));
index++;
}
}