1 Creating and destroying a memcached_st
2 ======================================
7 #include <libmemcached/memcached.h>
8 Compile and link with -lmemcached
10 .. type:: struct memcached_st memcached_st
12 .. function:: memcached_st* memcached_create(memcached_st *ptr)
14 .. function:: void memcached_free(memcached_st *ptr)
16 .. function:: memcached_st* memcached_clone(memcached_st *destination, memcached_st *source)
18 .. function:: void memcached_servers_reset(memcached_st)
23 `memcached_create` is used to create a `memcached_st` structure that will then
24 be used by other `libmemcached` functions to communicate with the server. You
25 should either pass a statically declared `memcached_st` to `memcached_create` or
26 a NULL. If a NULL passed in then a structure is allocated for you.
28 Please note, when you write new application use `memcached` over
31 `memcached_clone` is similar to `memcached_create` but it copies the defaults
32 and list of servers from the source `memcached_st`. If you pass a null as the
33 argument for the source to clone, it is the same as a call to
34 `memcached_create`. If the destination argument is NULL a `memcached_st` will be
37 `memcached_servers_reset` allows you to zero out the list of servers that the
40 To clean up memory associated with a `memcached_st` structure you should pass it
41 to `memcached_free` when you are finished using it. `memcached_free` is the only
42 way to make sure all memory is deallocated when you finish using the structure.
44 You may wish to avoid using `memcached_create` or `memcached_clone` with a stack
45 based allocation. The most common issues related to ABI safety involve heap
51 `memcached_create` returns a pointer to the `memcached_st` that was created (or
52 initialized). On an allocation failure, it returns NULL.
54 `memcached_clone` returns a pointer to the `memcached_st` that was created (or
55 initialized). On an allocation failure, it returns NULL.
62 :manpage:`memcached(1)`
63 :manpage:`libmemcached(3)`
67 * :manpage:`memcached(1)`
68 * :doc:`../libmemcached`