From: Date: Fri, 18 Jan 2008 19:09:30 +0000 (-0500) Subject: More on clone/cleanup callbacks X-Git-Tag: 0.14~11 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=8820c618bc66991f0ea6cb45cd8deb0fc0fc560e;p=awesomized%2Flibmemcached More on clone/cleanup callbacks --- 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; }