X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=lib%2Fmemcached.c;h=31c12ab3158bc52af7665376171816157f27e3c5;hb=7b30155c3b85ef95cd1841efb1b109aa918ed52b;hp=30099c39ff7a2f643f2edd9caaaddb0ee5b0d979;hpb=e2a313f77fd825bdaec9db1649b0549b2d5962c2;p=awesomized%2Flibmemcached diff --git a/lib/memcached.c b/lib/memcached.c index 30099c39..31c12ab3 100644 --- a/lib/memcached.c +++ b/lib/memcached.c @@ -5,8 +5,9 @@ memcached_st *memcached_create(memcached_st *ptr) { - memcached_string_st *string_ptr; - if (!ptr) + memcached_result_st *result_ptr; + + if (ptr == NULL) { ptr= (memcached_st *)malloc(sizeof(memcached_st)); @@ -20,8 +21,8 @@ memcached_st *memcached_create(memcached_st *ptr) { memset(ptr, 0, sizeof(memcached_st)); } - string_ptr= memcached_string_create(ptr, &ptr->result_buffer, 0); - WATCHPOINT_ASSERT(string_ptr); + result_ptr= memcached_result_create(ptr, &ptr->result); + WATCHPOINT_ASSERT(result_ptr); ptr->poll_timeout= MEMCACHED_DEFAULT_TIMEOUT; ptr->distribution= MEMCACHED_DISTRIBUTION_MODULA; @@ -32,11 +33,19 @@ void memcached_free(memcached_st *ptr) { /* If we have anything open, lets close it now */ memcached_quit(ptr); - memcached_server_list_free(ptr->hosts); - memcached_string_free(&ptr->result_buffer); + server_list_free(ptr, ptr->hosts); + memcached_result_free(&ptr->result); + + if (ptr->on_cleanup) + ptr->on_cleanup(ptr); if (ptr->is_allocated == MEMCACHED_ALLOCATED) - free(ptr); + { + if (ptr->call_free) + ptr->call_free(ptr, ptr); + else + free(ptr); + } else ptr->is_allocated= MEMCACHED_USED; } @@ -82,6 +91,16 @@ memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr) new_clone->poll_timeout= ptr->poll_timeout; new_clone->distribution= ptr->distribution; new_clone->hash= ptr->hash; + new_clone->user_data= ptr->user_data; + + new_clone->on_clone= ptr->on_clone; + new_clone->on_cleanup= ptr->on_cleanup; + new_clone->call_free= ptr->call_free; + new_clone->call_malloc= ptr->call_malloc; + new_clone->call_realloc= ptr->call_realloc; + + if (ptr->on_clone) + ptr->on_clone(ptr, new_clone); return new_clone; }