Fixed bug reported by Stuart Midgley about what happens when there are no
[awesomized/libmemcached] / lib / memcached.c
index 157dc89f24580af2707d9edbf8ffda26d7d98d84..5f0d98207e3269ca9c3d21f8e991c927edaa9dfa 100644 (file)
@@ -5,6 +5,7 @@
 
 memcached_st *memcached_create(memcached_st *ptr)
 {
+  memcached_string_st *string_ptr;
   if (!ptr)
   {
     ptr= (memcached_st *)malloc(sizeof(memcached_st));
@@ -19,6 +20,8 @@ memcached_st *memcached_create(memcached_st *ptr)
   {
     memset(ptr, 0, sizeof(memcached_st));
   }
+  string_ptr= memcached_string_create(ptr, &ptr->result_buffer, 0);
+  WATCHPOINT_ASSERT(string_ptr);
 
   return ptr;
 }
@@ -32,12 +35,19 @@ void memcached_free(memcached_st *ptr)
     ptr->hosts= NULL;
   }
 
+  memcached_string_free(&ptr->result_buffer);
+
   if (ptr->is_allocated == MEMCACHED_ALLOCATED)
     free(ptr);
   else
     memset(ptr, 0, sizeof(memcached_st));
 }
 
+/*
+  clone is the destination, while ptr is the structure to clone.
+  If ptr is NULL the call is the same as if a memcached_create() was
+  called.
+*/
 memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr)
 {
   memcached_return rc;