Updated release notes
[awesomized/libmemcached] / libmemcached / memcached_string.c
index 3cc894d52c9ff55426cf3d5a368fd2175b59232b..3bac225afe2e5e80ae0aee780bb25aa1edd6e845 100644 (file)
@@ -41,21 +41,17 @@ memcached_string_st *memcached_string_create(memcached_st *ptr, memcached_string
 
   /* Saving malloc calls :) */
   if (string)
-  {
     memset(string, 0, sizeof(memcached_string_st));
-    string->is_allocated= MEMCACHED_NOT_ALLOCATED;
-  }
   else
   {
     if (ptr->call_malloc)
       string= (memcached_string_st *)ptr->call_malloc(ptr, sizeof(memcached_string_st));
     else
-      string= (memcached_string_st *)malloc(sizeof(memcached_string_st));
+      string= (memcached_string_st *)calloc(1, sizeof(memcached_string_st));
 
     if (string == NULL)
       return NULL;
-    memset(string, 0, sizeof(memcached_string_st));
-    string->is_allocated= MEMCACHED_ALLOCATED;
+    string->is_allocated= true;
   }
   string->block_size= MEMCACHED_BLOCK_SIZE;
   string->root= ptr;
@@ -81,8 +77,6 @@ memcached_return memcached_string_append_character(memcached_string_st *string,
 {
   memcached_return rc;
 
-  WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
-
   rc=  memcached_string_check(string, 1);
 
   if (rc != MEMCACHED_SUCCESS)
@@ -99,8 +93,6 @@ memcached_return memcached_string_append(memcached_string_st *string,
 {
   memcached_return rc;
 
-  WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
-
   rc= memcached_string_check(string, length);
 
   if (rc != MEMCACHED_SUCCESS)
@@ -120,8 +112,6 @@ char *memcached_string_c_copy(memcached_string_st *string)
 {
   char *c_ptr;
 
-  WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
-
   if (memcached_string_length(string) == 0)
     return NULL;
 
@@ -141,7 +131,6 @@ char *memcached_string_c_copy(memcached_string_st *string)
 
 memcached_return memcached_string_reset(memcached_string_st *string)
 {
-  WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED);
   string->end= string->string;
   
   return MEMCACHED_SUCCESS;
@@ -160,7 +149,7 @@ void memcached_string_free(memcached_string_st *ptr)
       free(ptr->string);
   }
 
-  if (ptr->is_allocated == MEMCACHED_ALLOCATED)
+  if (ptr->is_allocated)
   {
     if (ptr->root->call_free)
       ptr->root->call_free(ptr->root, ptr);
@@ -168,5 +157,5 @@ void memcached_string_free(memcached_string_st *ptr)
       free(ptr);
   }
   else
-    ptr->is_allocated= MEMCACHED_USED;
+    memset(ptr, 0, sizeof(memcached_string_st));
 }