X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_string.c;h=3bac225afe2e5e80ae0aee780bb25aa1edd6e845;hb=7582050eb5e2bdc7e055c84d639a7cb5b407cd4c;hp=3cc894d52c9ff55426cf3d5a368fd2175b59232b;hpb=2b312deb8b7b3f662b492f94a13e673723387724;p=awesomized%2Flibmemcached diff --git a/libmemcached/memcached_string.c b/libmemcached/memcached_string.c index 3cc894d5..3bac225a 100644 --- a/libmemcached/memcached_string.c +++ b/libmemcached/memcached_string.c @@ -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)); }