X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=libmemcached%2Fresult.c;h=6e58eebd998f2f2f2362f1a018b8db2cb1fb72ec;hb=c4dbc7e56b01545e25bc95ba122c79d4a2631a99;hp=907823d8b5b21d4fb83768d071be3a1f1ff263a9;hpb=25c32fd878df9103de46b2e3b03265d41e4dde1b;p=awesomized%2Flibmemcached diff --git a/libmemcached/result.c b/libmemcached/result.c index 907823d8..6e58eebd 100644 --- a/libmemcached/result.c +++ b/libmemcached/result.c @@ -18,7 +18,7 @@ #include "common.h" static inline void _result_init(memcached_result_st *self, - const memcached_st *memc) + memcached_st *memc) { self->item_flags= 0; self->item_expiration= 0; @@ -32,7 +32,6 @@ memcached_result_st *memcached_result_create(const memcached_st *memc, memcached_result_st *ptr) { WATCHPOINT_ASSERT(memc); - WATCHPOINT_ASSERT(memc->options.is_initialized); /* Saving malloc calls :) */ if (ptr) @@ -51,9 +50,9 @@ memcached_result_st *memcached_result_create(const memcached_st *memc, ptr->options.is_initialized= true; - _result_init(ptr, memc); + _result_init(ptr, (memcached_st *)memc); - ptr->root= memc; + WATCHPOINT_SET(ptr->value.options.is_initialized= false); memcached_string_create(memc, &ptr->value, 0); WATCHPOINT_ASSERT_INITIALIZED(&ptr->value); WATCHPOINT_ASSERT(ptr->value.string == NULL); @@ -92,5 +91,54 @@ 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); + memcached_return_t rc= memcached_string_append(&ptr->value, value, length); + + if (rc == MEMCACHED_MEMORY_ALLOCATION_FAILURE) + { + memcached_set_errno(ptr->root, errno, NULL); + } + + return rc; +} + +const char *memcached_result_key_value(const memcached_result_st *self) +{ + return self->key_length ? self->item_key : NULL; +} + +size_t memcached_result_key_length(const memcached_result_st *self) +{ + return self->key_length; +} + +const char *memcached_result_value(const memcached_result_st *self) +{ + const memcached_string_st *sptr= &self->value; + return memcached_string_value(sptr); +} + +size_t memcached_result_length(const memcached_result_st *self) +{ + const memcached_string_st *sptr= &self->value; + return memcached_string_length(sptr); +} + +uint32_t memcached_result_flags(const memcached_result_st *self) +{ + return self->item_flags; +} + +uint64_t memcached_result_cas(const memcached_result_st *self) +{ + return self->item_cas; +} + +void memcached_result_set_flags(memcached_result_st *self, uint32_t flags) +{ + self->item_flags= flags; +} + +void memcached_result_set_expiration(memcached_result_st *self, time_t expiration) +{ + self->item_expiration= expiration; }