X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fmemcached_result.c;h=0d77130db58857a437089073e513afef97f00f47;hb=9141e90dccb732d6e7ef10ea248ce2fd7d1ef46b;hp=cf3894bef3b7545fcdaca9be56d6e1883f25b2a3;hpb=8fce86636639afaeac4ca0e869e8bcd833324a62;p=awesomized%2Flibmemcached diff --git a/libmemcached/memcached_result.c b/libmemcached/memcached_result.c index cf3894be..0d77130d 100644 --- a/libmemcached/memcached_result.c +++ b/libmemcached/memcached_result.c @@ -11,31 +11,40 @@ 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) - ptr= (memcached_result_st *)memc->call_malloc(memc, sizeof(memcached_result_st)); - else - ptr= (memcached_result_st *)malloc(sizeof(memcached_result_st)); + ptr= memc->call_malloc(memc, sizeof(memcached_result_st)); 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, const 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 +52,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; }