Removed all valgrind warning. Thought this error persists and I can not see
[m6w6/libmemcached] / lib / memcached_connect.c
index d0658f33e57d2e92c267b8442154d49cba06e7a2..105e7d20d82074f89f5689c854249376e6040f92 100644 (file)
@@ -13,8 +13,9 @@ memcached_return memcached_server_add(memcached_st *ptr, char *hostname, unsigne
 
 
   new_host_list= (memcached_host_st *)realloc(ptr->hosts, sizeof(memcached_host_st) * (ptr->number_of_hosts+1));
-  memset((new_host_list + (sizeof(memcached_host_st) * ptr->number_of_hosts)) - sizeof(memcached_host_st), 
-         0, sizeof(memcached_host_st));
+  if (!new_host_list)
+    return MEMCACHED_MEMORY_ALLOCATION_FAILURE;
+  memset(&new_host_list[ptr->number_of_hosts], 0, sizeof(memcached_host_st));
   
   if (!new_host_list)
     return MEMCACHED_MEMORY_ALLOCATION_FAILURE;