From: Brian Aker Date: Sat, 6 Oct 2012 08:14:15 +0000 (-0400) Subject: Add new method which allows someone to "take" a value from a result object. X-Git-Tag: 1.0.12~9 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=1adc67d1609fd71308b822e153dcb08ad7fbf9c2;p=awesomized%2Flibmemcached Add new method which allows someone to "take" a value from a result object. Updates bootstrap.sh to latest version. --- 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