+ /* TODO, Document why we picked these defaults */
+ self->io_msg_watermark= 500;
+ self->io_bytes_watermark= 65 * 1024;
+
+ self->tcp_keepidle= 0;
+
+ self->io_key_prefetch= 0;
+ self->poll_timeout= MEMCACHED_DEFAULT_TIMEOUT;
+ self->connect_timeout= MEMCACHED_DEFAULT_CONNECT_TIMEOUT;
+ self->retry_timeout= 0;
+
+ self->send_size= -1;
+ self->recv_size= -1;
+
+ self->user_data= NULL;
+ self->number_of_replicas= 0;
+ hash_ptr= hashkit_create(&self->distribution_hashkit);
+ if (! hash_ptr)
+ return false;
+
+ self->allocators= memcached_allocators_return_default();
+
+ self->on_clone= NULL;
+ self->on_cleanup= NULL;
+ self->get_key_failure= NULL;
+ self->delete_trigger= NULL;
+ self->callbacks= NULL;
+ self->sasl.callbacks= NULL;
+ self->sasl.is_allocated= false;
+
+ self->error_messages= NULL;
+ self->prefix_key= NULL;
+ self->configure.filename= NULL;
+
+ return true;
+}
+
+static void _free(memcached_st *ptr, bool release_st)
+{
+ /* If we have anything open, lets close it now */
+ send_quit(ptr);
+ memcached_server_list_free(memcached_server_list(ptr));
+ memcached_result_free(&ptr->result);
+
+ memcached_virtual_bucket_free(ptr);
+
+ if (ptr->last_disconnected_server)
+ memcached_server_free(ptr->last_disconnected_server);
+
+ if (ptr->on_cleanup)
+ ptr->on_cleanup(ptr);
+
+ if (ptr->ketama.continuum)
+ libmemcached_free(ptr, ptr->ketama.continuum);
+
+ memcached_array_free(ptr->prefix_key);
+ ptr->prefix_key= NULL;
+
+ memcached_error_free(ptr);
+
+ if (ptr->sasl.callbacks)
+ {
+#ifdef LIBMEMCACHED_WITH_SASL_SUPPORT
+ memcached_destroy_sasl_auth_data(ptr);
+#endif
+ }
+
+ if (release_st)
+ {
+ memcached_array_free(ptr->configure.filename);
+ ptr->configure.filename= NULL;
+ }
+
+ if (memcached_is_allocated(ptr) && release_st)
+ {
+ libmemcached_free(ptr, ptr);
+ }
+}
+
+memcached_st *memcached_create(memcached_st *ptr)
+{