- if (ptr->hosts)
- {
- for (host_ptr= ptr->hosts; host_ptr; host_ptr= host_ptr->next)
- prev_ptr= host_ptr;
- host_ptr= (memcached_host_st *)malloc(sizeof(memcached_host_st));
- if (!host_ptr)
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- prev_ptr->next= host_ptr;
- }
- else
- {
- ptr->hosts=
- host_ptr= (memcached_host_st *)malloc(sizeof(memcached_host_st));
- if (!host_ptr)
- return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
- }
-
- memset(host_ptr, 0, sizeof(memcached_host_st));
- host_ptr->hostname= (char *)malloc(sizeof(char) * strlen(hostname));