+ /* If we have anything open, lets close it now */
+ memcached_quit(ptr);
+ 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)
+ {
+ if (ptr->call_free)
+ ptr->call_free(ptr, ptr);
+ else
+ free(ptr);
+ }
+ else
+ ptr->is_allocated= MEMCACHED_USED;
+}
+
+/*
+ clone is the destination, while ptr is the structure to clone.
+ If ptr is NULL the call is the same as if a memcached_create() was
+ called.
+*/
+memcached_st *memcached_clone(memcached_st *clone, memcached_st *ptr)
+{
+ memcached_return rc= MEMCACHED_SUCCESS;
+ memcached_st *new_clone;
+
+ if (ptr == NULL)
+ return memcached_create(clone);
+
+ if (ptr->is_allocated == MEMCACHED_USED)
+ {
+ WATCHPOINT_ASSERT(0);
+ return NULL;
+ }
+
+ new_clone= memcached_create(clone);
+
+ if (new_clone == NULL)
+ return NULL;
+