libmemcached/memcached.cc
/*
  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.
*/
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.
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;
  if (not source)
    return memcached_create(clone);
  if (clone && memcached_is_allocated(clone))
  {
    return NULL;
  }
  memcached_st *new_clone= memcached_create(clone);
  if (not new_clone)
    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;
  new_clone->ketama.weighted= source->ketama.weighted;
#ifdef LIBMEMCACHED_WITH_ZK_INTEGRATION
  new_clone->server_manager= source->server_manager;
  ((arcus_st *)new_clone)->proxy= ((arcus_st *)source)->proxy;
#endif
  if (not hashkit_clone(&new_clone->hashkit, &source->hashkit))
  {
    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;
  new_clone->tcp_keepidle= source->tcp_keepidle;
  if (memcached_server_count(source))
  {
    rc= memcached_push(new_clone, source);
  }
  if (memcached_failed(rc))
  {
    memcached_free(new_clone);
    return NULL;
  }
  new_clone->_namespace= memcached_array_clone(new_clone, source->_namespace);
  new_clone->configure.filename= memcached_array_clone(new_clone, source->_namespace);
#ifdef UPDATE_HASH_RING_OF_FETCHED_MC
  new_clone->configure.ketama_version= source->configure.ketama_version;
#endif
  new_clone->configure.version= source->configure.version;
  if (LIBMEMCACHED_WITH_SASL_SUPPORT and source->sasl.callbacks)
  {
    if (memcached_failed(memcached_clone_sasl(new_clone, source)))
    {
      memcached_free(new_clone);
      return NULL;
    }
  }
  if (source->on_clone)
  {
    source->on_clone(new_clone, source);
  }
  return new_clone;
}
memcached_st * memcached_clone ( memcached_st * clone , const memcached_st * source ) { memcached_return_t rc = MEMCACHED_SUCCESS ; if ( not source ) return memcached_create ( clone ) ; if ( clone && memcached_is_allocated ( clone ) ) { return NULL ; } memcached_st * new_clone = memcached_create ( clone ) ; if ( not new_clone ) 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 ; new_clone -> ketama . weighted = source -> ketama . weighted ; #ifdef LIBMEMCACHED_WITH_ZK_INTEGRATION new_clone -> server_manager = source -> server_manager ; ( ( arcus_st * ) new_clone ) -> proxy = ( ( arcus_st * ) source ) -> proxy ; #endif if ( not hashkit_clone ( & new_clone -> hashkit , & source -> hashkit ) ) { 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 ; new_clone -> tcp_keepidle = source -> tcp_keepidle ; if ( memcached_server_count ( source ) ) { rc = memcached_push ( new_clone , source ) ; } if ( memcached_failed ( rc ) ) { memcached_free ( new_clone ) ; return NULL ; } new_clone -> _namespace = memcached_array_clone ( new_clone , source -> _namespace ) ; new_clone -> configure . filename = memcached_array_clone ( new_clone , source -> _namespace ) ; #ifdef UPDATE_HASH_RING_OF_FETCHED_MC new_clone -> configure . ketama_version = source -> configure . ketama_version ; #endif new_clone -> configure . version = source -> configure . version ; if ( LIBMEMCACHED_WITH_SASL_SUPPORT and source -> sasl . callbacks ) { if ( memcached_failed ( memcached_clone_sasl ( new_clone , source ) ) ) { memcached_free ( new_clone ) ; return NULL ; } } if ( source -> on_clone ) { source -> on_clone ( new_clone , source ) ; } return new_clone ; }
clone is the destination, while source is the structure to clone.
clone is the destination while source is the structure to clone .