X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;ds=sidebyside;f=libmemcached%2Fresult.c;h=03cd4fc33bd03919f323fcd1f6bd08ca0e1be047;hb=1d8231fc194a56976c5bb14a75ff548ef5440191;hp=14a0774e3eb3b9e4b9ec4a5f7a4fcb5895d5eaad;hpb=7c7750f02368b570353ea109f23a0ea26d226e02;p=awesomized%2Flibmemcached diff --git a/libmemcached/result.c b/libmemcached/result.c index 14a0774e..03cd4fc3 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,15 +9,15 @@ * */ -/* +/* 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); @@ -29,7 +29,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; @@ -72,10 +72,31 @@ 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 { ptr->options.is_initialized= false; } } + + +char *memcached_result_value(memcached_result_st *ptr) +{ + memcached_string_st *sptr= &ptr->value; + return memcached_string_value(sptr); +} + +size_t memcached_result_length(memcached_result_st *ptr) +{ + memcached_string_st *sptr= &ptr->value; + return memcached_string_length(sptr); +} +