X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fresult.c;h=bca92740069afc883259848effcdcd77cdf5dcab;hb=3f74469068084eab48af568f477360fb24dc8bcb;hp=14a0774e3eb3b9e4b9ec4a5f7a4fcb5895d5eaad;hpb=7c7750f02368b570353ea109f23a0ea26d226e02;p=m6w6%2Flibmemcached diff --git a/libmemcached/result.c b/libmemcached/result.c index 14a0774e..bca92740 100644 --- a/libmemcached/result.c +++ b/libmemcached/result.c @@ -1,5 +1,5 @@ /* LibMemcached - * Copyright (C) 2006-2009 Brian Aker + * Copyright (C) 2006-2009 Brian Aker * All rights reserved. * * Use and distribution licensed under the BSD license. See @@ -9,18 +9,19 @@ * */ -/* +/* memcached_result_st are used to internally represent the return values from - memcached. We use a structure so that long term as identifiers are added - to memcached we will be able to absorb new attributes without having + memcached. We use a structure so that long term as identifiers are added + to memcached we will be able to absorb new attributes without having to addjust the entire API. */ #include "common.h" -memcached_result_st *memcached_result_create(memcached_st *memc, +memcached_result_st *memcached_result_create(memcached_st *memc, memcached_result_st *ptr) { - WATCHPOINT_ASSERT(memc && memc->options.is_initialized); + WATCHPOINT_ASSERT(memc); + WATCHPOINT_ASSERT(memc->options.is_initialized); /* Saving malloc calls :) */ if (ptr) @@ -29,7 +30,7 @@ memcached_result_st *memcached_result_create(memcached_st *memc, } else { - ptr= memc->call_malloc(memc, sizeof(memcached_result_st)); + ptr= memc->call_calloc(memc, 1, sizeof(memcached_result_st)); if (ptr == NULL) return NULL; @@ -55,14 +56,6 @@ void memcached_result_reset(memcached_result_st *ptr) ptr->expiration= 0; } -/* - NOTE turn into macro -*/ -memcached_return_t 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) @@ -72,7 +65,14 @@ void memcached_result_free(memcached_result_st *ptr) if (memcached_is_allocated(ptr)) { - free(ptr); + if (ptr->root != NULL) + { + ptr->root->call_free(ptr->root, ptr); + } + else + { + free(ptr); + } } else {