X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_result.c;h=8d376f680fd45ced6ef1cd6a88b4f3f21ed19666;hb=93b444da927e8e0ee3fd844ea617d96a04fbaa97;hp=cf3894bef3b7545fcdaca9be56d6e1883f25b2a3;hpb=8fce86636639afaeac4ca0e869e8bcd833324a62;p=awesomized%2Flibmemcached diff --git a/libmemcached/memcached_result.c b/libmemcached/memcached_result.c index cf3894be..8d376f68 100644 --- a/libmemcached/memcached_result.c +++ b/libmemcached/memcached_result.c @@ -11,10 +11,7 @@ memcached_result_st *memcached_result_create(memcached_st *memc, { /* Saving malloc calls :) */ if (ptr) - { memset(ptr, 0, sizeof(memcached_result_st)); - ptr->is_allocated= MEMCACHED_NOT_ALLOCATED; - } else { if (memc->call_malloc) @@ -25,17 +22,33 @@ memcached_result_st *memcached_result_create(memcached_st *memc, if (ptr == NULL) return NULL; memset(ptr, 0, sizeof(memcached_result_st)); - ptr->is_allocated= MEMCACHED_ALLOCATED; + ptr->is_allocated= true; } ptr->root= memc; memcached_string_create(memc, &ptr->value, 0); WATCHPOINT_ASSERT(ptr->value.string == NULL); - WATCHPOINT_ASSERT(ptr->value.is_allocated == MEMCACHED_NOT_ALLOCATED); return ptr; } +void memcached_result_reset(memcached_result_st *ptr) +{ + ptr->key_length= 0; + memcached_string_reset(&ptr->value); + ptr->flags= 0; + ptr->cas= 0; + ptr->expiration= 0; +} + +/* + NOTE turn into macro +*/ +memcached_return memcached_result_set_value(memcached_result_st *ptr, char *value, size_t length) +{ + return memcached_string_append(&ptr->value, value, length); +} + void memcached_result_free(memcached_result_st *ptr) { if (ptr == NULL) @@ -43,8 +56,6 @@ void memcached_result_free(memcached_result_st *ptr) memcached_string_free(&ptr->value); - if (ptr->is_allocated == MEMCACHED_ALLOCATED) + if (ptr->is_allocated) free(ptr); - else - ptr->is_allocated= MEMCACHED_USED; }