memcached_st *memcached_create(memcached_st *ptr)
{
memcached_result_st *result_ptr;
- if (!ptr)
+
+ if (ptr == NULL)
{
ptr= (memcached_st *)malloc(sizeof(memcached_st));
{
/* If we have anything open, lets close it now */
memcached_quit(ptr);
- memcached_server_list_free(ptr->hosts);
+ 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;
}
memcached_return rc= MEMCACHED_SUCCESS;
memcached_st *new_clone;
+ WATCHPOINT;
if (ptr == NULL)
return memcached_create(clone);
return NULL;
}
+ WATCHPOINT;
new_clone= memcached_create(clone);
if (new_clone == NULL)
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;
}