From 8820c618bc66991f0ea6cb45cd8deb0fc0fc560e Mon Sep 17 00:00:00 2001 From: Date: Fri, 18 Jan 2008 14:09:30 -0500 Subject: [PATCH] More on clone/cleanup callbacks --- lib/memcached.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/memcached.c b/lib/memcached.c index 25a287ad..5471eba6 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -35,6 +35,9 @@ void memcached_free(memcached_st *ptr) memcached_server_list_free(ptr->hosts); memcached_result_free(&ptr->result); + if (ptr->on_cleanup) + ptr->on_cleanup(ptr); + if (ptr->is_allocated == MEMCACHED_ALLOCATED) free(ptr); else @@ -52,7 +55,14 @@ memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr) memcached_st *new_clone; if (ptr == NULL) - return memcached_create(clone); + { + new_clone= memcached_create(clone); + + if (ptr->on_clone) + ptr->on_clone(NULL, new_clone); + + return new_clone; + } if (ptr->is_allocated == MEMCACHED_USED) { @@ -84,5 +94,8 @@ memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr) new_clone->hash= ptr->hash; new_clone->user_data= ptr->user_data; + if (ptr->on_clone) + ptr->on_clone(ptr, new_clone); + return new_clone; } -- 2.30.2