From 1adc67d1609fd71308b822e153dcb08ad7fbf9c2 Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Sat, 6 Oct 2012 04:14:15 -0400 Subject: [PATCH] Add new method which allows someone to "take" a value from a result object. Updates bootstrap.sh to latest version. --- .bzrignore | 9 +++---- ChangeLog | 3 +++ bootstrap.sh | 32 ++++++++++++++++++++++++- docs/memcached_result_st.rst | 7 ++++++ libmemcached-1.0/result.h | 3 +++ libmemcached/result.cc | 6 +++++ tests/libmemcached-1.0/mem_functions.cc | 4 ++++ 7 files changed, 59 insertions(+), 5 deletions(-) diff --git a/.bzrignore b/.bzrignore index dd7926d9..866ad779 100644 --- a/.bzrignore +++ b/.bzrignore @@ -34,6 +34,7 @@ TAGS aclocal.m4 autom4te.cache autoscan.log +build-aux/ clients/memaslap clients/memcapable clients/memcat @@ -95,12 +96,16 @@ libtest/unittest libtest/version.h libtest/wait libtool +m4/.git m4/libtool.m4 m4/libtool.m4 m4/ltoptions.m4 m4/ltsugar.m4 m4/ltversion.m4 m4/lt~obsolete.m4 +man/*.1 +man/*.3 +man/*.8 memcached/.git memcached/.gitignore memcached/memcached @@ -150,7 +155,3 @@ tests/testudp tests/var/ tmp_chroot unittests/unittests -m4/.git -man/*.1 -man/*.3 -man/*.8 diff --git a/ChangeLog b/ChangeLog index 1d9524c1..6a5c44fe 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,6 @@ +1.0.12 +* Added memcached_result_take_value(). + 1.0.11 Sun Sep 16 20:32:13 EDT 2012 * Removed custom version of memcached. * Updated hardening rules. diff --git a/bootstrap.sh b/bootstrap.sh index 74637a89..9c873188 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -281,7 +281,32 @@ run() { $@ $ARGS } +parse_command_line_options() { + + if ! options=$(getopt -o c --long configure -n 'bootstrap' -- "$@"); then + exit 1 + fi + + eval set -- "$options" + + while [ $# -gt 0 ]; do + case $1 in + -c | --configure ) + CONFIGURE_OPTION="yes" ; shift;; + -- ) + shift; break;; + -* ) + echo "$0: error - unrecognized option $1" 1>&2; exit 1;; + *) + break;; + esac + done +} + + + bootstrap() { + parse_command_line_options $@ determine_target_platform if [ -d .git ]; then @@ -345,6 +370,10 @@ bootstrap() { run $AUTORECONF $AUTORECONF_FLAGS || die "Cannot execute $AUTORECONF $AUTORECONF_FLAGS" configure_target_platform + + if [ "$CONFIGURE_OPTION" == "yes" ]; then + exit + fi # Backwards compatibility if [ -n "$VALGRIND" ]; then @@ -382,8 +411,9 @@ bootstrap() { export -n VCS_CHECKOUT export -n PLATFORM export -n TARGET_PLATFORM +CONFIGURE_OPTION=no VCS_CHECKOUT= PLATFORM=unknown TARGET_PLATFORM=unknown -bootstrap +bootstrap $@ diff --git a/docs/memcached_result_st.rst b/docs/memcached_result_st.rst index 3cd9afe2..9b60f187 100644 --- a/docs/memcached_result_st.rst +++ b/docs/memcached_result_st.rst @@ -20,6 +20,8 @@ SYNOPSIS .. c:function:: const char *memcached_result_value (memcached_result_st *ptr) +.. c:function:: char *memcached_result_take_value (memcached_result_st *ptr) + .. c:function:: size_t memcached_result_length (const memcached_result_st *ptr) .. c:function:: uint32_t memcached_result_flags (const memcached_result_st *result) @@ -67,6 +69,11 @@ the current result object. :c:func:`memcached_result_value` returns the result value associated with the current result object. +:c:func:`memcached_result_take_value` returns and hands over the result value +associated with the current result object. You must call free() to release this +value, unless you have made use of a custom allocator. Use of a custom +allocator requires that you create your own custom free() to release it. + :c:func:`memcached_result_length` returns the result length associated with the current result object. diff --git a/libmemcached-1.0/result.h b/libmemcached-1.0/result.h index a1f0aa96..615957f3 100644 --- a/libmemcached-1.0/result.h +++ b/libmemcached-1.0/result.h @@ -63,6 +63,9 @@ size_t memcached_result_key_length(const memcached_result_st *self); LIBMEMCACHED_API const char *memcached_result_value(const memcached_result_st *self); +LIBMEMCACHED_API +char *memcached_result_take_value(memcached_result_st *self); + LIBMEMCACHED_API size_t memcached_result_length(const memcached_result_st *self); diff --git a/libmemcached/result.cc b/libmemcached/result.cc index e7bac559..c3e0b452 100644 --- a/libmemcached/result.cc +++ b/libmemcached/result.cc @@ -162,6 +162,12 @@ size_t memcached_result_length(const memcached_result_st *self) return memcached_string_length(sptr); } +char *memcached_result_take_value(memcached_result_st *self) +{ + memcached_string_st *sptr= &self->value; + return memcached_string_take_value(sptr); +} + uint32_t memcached_result_flags(const memcached_result_st *self) { return self->item_flags; diff --git a/tests/libmemcached-1.0/mem_functions.cc b/tests/libmemcached-1.0/mem_functions.cc index 2155f7f3..10b84683 100644 --- a/tests/libmemcached-1.0/mem_functions.cc +++ b/tests/libmemcached-1.0/mem_functions.cc @@ -4683,6 +4683,10 @@ test_return_t regression_994772_TEST(memcached_st* memc) uint64_t cas_value= memcached_result_cas(results); test_true(cas_value); + char* take_value= memcached_result_take_value(results); + test_strcmp(__func__, take_value); + free(take_value); + memcached_result_free(results); // Bad cas value, sanity check -- 2.30.2