6 memcached_st
*memcached_create(memcached_st
*ptr
)
8 memcached_string_st
*string_ptr
;
11 ptr
= (memcached_st
*)malloc(sizeof(memcached_st
));
14 return NULL
; /* MEMCACHED_MEMORY_ALLOCATION_FAILURE */
16 memset(ptr
, 0, sizeof(memcached_st
));
17 ptr
->is_allocated
= MEMCACHED_ALLOCATED
;
21 memset(ptr
, 0, sizeof(memcached_st
));
23 string_ptr
= memcached_string_create(ptr
, &ptr
->result_buffer
, 0);
24 WATCHPOINT_ASSERT(string_ptr
);
25 ptr
->poll_timeout
= -1;
26 ptr
->distribution
= MEMCACHED_DISTRIBUTION_MODULUS
;
31 void memcached_free(memcached_st
*ptr
)
36 memcached_server_list_free(ptr
->hosts
);
40 memcached_string_free(&ptr
->result_buffer
);
42 if (ptr
->is_allocated
== MEMCACHED_ALLOCATED
)
45 ptr
->is_allocated
= MEMCACHED_USED
;
49 clone is the destination, while ptr is the structure to clone.
50 If ptr is NULL the call is the same as if a memcached_create() was
53 memcached_st
*memcached_clone(memcached_st
*clone
, memcached_st
*ptr
)
56 memcached_st
*new_clone
;
59 return memcached_create(clone
);
61 new_clone
= memcached_create(clone
);
64 rc
= memcached_server_push(new_clone
, ptr
->hosts
);
66 if (rc
!= MEMCACHED_SUCCESS
)
68 memcached_free(new_clone
);
74 new_clone
->flags
= ptr
->flags
;
75 new_clone
->number_of_hosts
= ptr
->number_of_hosts
;
76 new_clone
->send_size
= ptr
->send_size
;
77 new_clone
->recv_size
= ptr
->recv_size
;
78 new_clone
->poll_timeout
= ptr
->poll_timeout
;
79 new_clone
->distribution
= ptr
->distribution
;