void memcached_result_free(memcached_result_st *ptr) { if (ptr == NULL) return; memcached_string_free(&ptr->value); if (memcached_is_allocated(ptr)) { WATCHPOINT_ASSERT(ptr->root); // Without a root, that means that result was not properly initialized. libmemcached_free(ptr->root, ptr); } else { ptr->options.is_initialized= false; } }
void memcached_free(memcached_st *ptr) { /* If we have anything open, lets close it now */ memcached_quit(ptr); server_list_free(ptr, memcached_server_list(ptr)); memcached_result_free(&ptr->result); if (ptr->on_cleanup) ptr->on_cleanup(ptr); if (ptr->continuum) libmemcached_free(ptr, ptr->continuum); if (memcached_is_allocated(ptr)) { libmemcached_free(ptr, ptr); } }
/* clone is the destination, while source is the structure to clone. If source is NULL the call is the same as if a memcached_create() was called. */ memcached_st *memcached_clone(memcached_st *clone, const memcached_st *source) { memcached_return_t rc= MEMCACHED_SUCCESS; memcached_st *new_clone; if (source == NULL) return memcached_create(clone); if (clone && memcached_is_allocated(clone)) { return NULL; } new_clone= memcached_create(clone); if (new_clone == NULL) return NULL; new_clone->flags= source->flags; new_clone->send_size= source->send_size; new_clone->recv_size= source->recv_size; new_clone->poll_timeout= source->poll_timeout; new_clone->connect_timeout= source->connect_timeout; new_clone->retry_timeout= source->retry_timeout; new_clone->distribution= source->distribution; hashkit_st *hash_ptr; hash_ptr= hashkit_clone(&new_clone->hashkit, &source->hashkit); if (! hash_ptr) { memcached_free(new_clone); return NULL; } hash_ptr= hashkit_clone(&new_clone->distribution_hashkit, &source->distribution_hashkit); if (! hash_ptr) { memcached_free(new_clone); return NULL; } new_clone->user_data= source->user_data; new_clone->snd_timeout= source->snd_timeout; new_clone->rcv_timeout= source->rcv_timeout; new_clone->on_clone= source->on_clone; new_clone->on_cleanup= source->on_cleanup; new_clone->allocators= source->allocators; new_clone->get_key_failure= source->get_key_failure; new_clone->delete_trigger= source->delete_trigger; new_clone->server_failure_limit= source->server_failure_limit; new_clone->io_msg_watermark= source->io_msg_watermark; new_clone->io_bytes_watermark= source->io_bytes_watermark; new_clone->io_key_prefetch= source->io_key_prefetch; new_clone->number_of_replicas= source->number_of_replicas; if (memcached_server_list(source)) rc= memcached_server_push(new_clone, memcached_server_list(source)); if (rc != MEMCACHED_SUCCESS) { memcached_free(new_clone); return NULL; } if (source->prefix_key_length) { strcpy(new_clone->prefix_key, source->prefix_key); new_clone->prefix_key_length= source->prefix_key_length; } rc= run_distribution(new_clone); if (rc != MEMCACHED_SUCCESS) { memcached_free(new_clone); return NULL; } if (source->on_clone) source->on_clone(new_clone, source); return new_clone; }