From: Trond Norbye Date: Sun, 21 Jun 2009 10:59:22 +0000 (+0200) Subject: Deprecate the old callback interface to set the memory allocators X-Git-Tag: 0.31~13^2 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=fd5128ba25070702e208e0f26961d6eb7dd76e5e;p=awesomized%2Flibmemcached Deprecate the old callback interface to set the memory allocators --- diff --git a/libmemcached/memcached_callback.c b/libmemcached/memcached_callback.c index de792d0e..3433585c 100644 --- a/libmemcached/memcached_callback.c +++ b/libmemcached/memcached_callback.c @@ -62,6 +62,7 @@ memcached_return memcached_callback_set(memcached_st *ptr, ptr->on_clone= func; break; } +#ifdef MEMCACHED_ENABLE_DEPRECATED case MEMCACHED_CALLBACK_MALLOC_FUNCTION: { memcached_malloc_function func= *(memcached_malloc_function *)&data; @@ -80,6 +81,7 @@ memcached_return memcached_callback_set(memcached_st *ptr, ptr->call_free= func; break; } +#endif case MEMCACHED_CALLBACK_GET_FAILURE: { memcached_trigger_key func= *(memcached_trigger_key *)&data; @@ -138,6 +140,7 @@ void *memcached_callback_get(memcached_st *ptr, *error= ptr->on_clone ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; return *(void **)&ptr->on_clone; } +#ifdef MEMCACHED_ENABLE_DEPRECATED case MEMCACHED_CALLBACK_MALLOC_FUNCTION: { *error= ptr->call_malloc ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; @@ -153,6 +156,7 @@ void *memcached_callback_get(memcached_st *ptr, *error= ptr->call_free ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; return *(void **)&ptr->call_free; } +#endif case MEMCACHED_CALLBACK_GET_FAILURE: { *error= ptr->get_key_failure ? MEMCACHED_SUCCESS : MEMCACHED_FAILURE; diff --git a/libmemcached/memcached_constants.h b/libmemcached/memcached_constants.h index 5fdede9a..5d0e31d0 100644 --- a/libmemcached/memcached_constants.h +++ b/libmemcached/memcached_constants.h @@ -110,15 +110,17 @@ typedef enum { } memcached_behavior; typedef enum { - MEMCACHED_CALLBACK_PREFIX_KEY, - MEMCACHED_CALLBACK_USER_DATA, - MEMCACHED_CALLBACK_CLEANUP_FUNCTION, - MEMCACHED_CALLBACK_CLONE_FUNCTION, - MEMCACHED_CALLBACK_MALLOC_FUNCTION, - MEMCACHED_CALLBACK_REALLOC_FUNCTION, - MEMCACHED_CALLBACK_FREE_FUNCTION, - MEMCACHED_CALLBACK_GET_FAILURE, - MEMCACHED_CALLBACK_DELETE_TRIGGER + MEMCACHED_CALLBACK_PREFIX_KEY = 0, + MEMCACHED_CALLBACK_USER_DATA = 1, + MEMCACHED_CALLBACK_CLEANUP_FUNCTION = 2, + MEMCACHED_CALLBACK_CLONE_FUNCTION = 3, +#ifdef MEMCACHED_ENABLE_DEPRECATED + MEMCACHED_CALLBACK_MALLOC_FUNCTION = 4, + MEMCACHED_CALLBACK_REALLOC_FUNCTION = 5, + MEMCACHED_CALLBACK_FREE_FUNCTION = 6, +#endif + MEMCACHED_CALLBACK_GET_FAILURE = 7, + MEMCACHED_CALLBACK_DELETE_TRIGGER = 8 } memcached_callback; typedef enum { diff --git a/tests/function.c b/tests/function.c index 5f83e1ea..7dea5974 100644 --- a/tests/function.c +++ b/tests/function.c @@ -3160,6 +3160,7 @@ static memcached_return set_prefix(memcached_st *memc) return MEMCACHED_SUCCESS; } +#ifdef MEMCACHED_ENABLE_DEPRECATED static memcached_return deprecated_set_memory_alloc(memcached_st *memc) { void *test_ptr= NULL; @@ -3204,6 +3205,7 @@ static memcached_return deprecated_set_memory_alloc(memcached_st *memc) } return MEMCACHED_SUCCESS; } +#endif static memcached_return set_memory_alloc(memcached_st *memc) { @@ -4536,7 +4538,9 @@ collection_st collection[] ={ {"poll_timeout", poll_timeout, 0, tests}, {"gets", enable_cas, 0, tests}, {"consistent", enable_consistent, 0, tests}, +#ifdef MEMCACHED_ENABLE_DEPRECATED {"deprecated_memory_allocators", deprecated_set_memory_alloc, 0, tests}, +#endif {"memory_allocators", set_memory_alloc, 0, tests}, {"prefix", set_prefix, 0, tests}, {"version_1_2_3", check_for_1_2_3, 0, version_1_2_3},