1MEMCACHED_SET_MEMORY_ALLOCATORlSi(b3m)emcached-aweMsEoMmCeACHED_SET_MEMORY_ALLOCATORS(3)
2
3
4

NAME

6       memcached_set_memory_allocators - libmemcached Documentation
7
8       Manage memory allocator functions
9

SYNOPSIS

11       #include <libmemcached/memcached.h>
12              Compile and link with -lmemcached
13
14       memcached_return_t  memcached_set_memory_allocators(memcached_st  *ptr,
15       memcached_malloc_fn     mem_malloc,     memcached_free_fn     mem_free,
16       memcached_realloc_fn  mem_realloc, memcached_calloc_fn mem_calloc, void
17       *context)
18
19              Parameters
20
21ptr -- pointer to an initialized memcached_st struct
22
23mem_malloc -- pointer to a memcached_malloc_fn callback
24
25mem_free -- pointer to a memcached_free_fn callback
26
27mem_realloc -- pointer to a memcached_realloc_fn  call‐
28                       back
29
30mem_calloc -- pointer to a memcached_calloc_fn callback
31
32context -- pointer to a user supplied context
33
34              Returns
35                     memcached_return_t indicating success
36
37       void         memcached_get_memory_allocators(memcached_st         *ptr,
38       memcached_malloc_fn    *mem_malloc,    memcached_free_fn     *mem_free,
39       memcached_realloc_fn *mem_realloc, memcached_calloc_fn *mem_calloc)
40
41              Parameters
42
43ptr -- pointer to an initialized memcached_st struct
44
45mem_malloc  --  pointer  to  store  the  address of the
46                       memcached_malloc_fn callback
47
48mem_free  --  pointer  to  store  the  address  of  the
49                       memcached_free_fn callback
50
51mem_realloc  --  pointer  to  store  the address of the
52                       memcached_realloc_fn callback
53
54mem_calloc -- pointer  to  store  the  address  of  the
55                       memcached_calloc_fn callback
56
57       void *memcached_get_memory_allocators_context(const memcached_st *ptr)
58
59              Parameters
60                     ptr -- pointer to an initialized memcached_st struct
61
62              Returns
63                     pointer to the user supplied context
64
65       typedef  void  *(*memcached_malloc_fn)(memcached_st  *ptr, const size_t
66       size, void *context)
67
68              Parameters
69
70ptr -- pointer to an initialized memcached_st struct
71
72size -- the number of bytes to allocate
73
74context -- pointer to the user supplied context
75
76              Returns
77                     pointer to at least size bytes of allocated memory
78
79       typedef void  *(*memcached_realloc_fn)(memcached_st  *ptr,  void  *mem,
80       const size_t size, void *context)
81
82              Parameters
83
84ptr -- pointer to an initialized memcached_st struct
85
86mem -- pointer to previously allocated memory
87
88size -- the number of bytes to allocate
89
90context -- pointer to the user supplied context
91
92              Returns
93                     pointer to at least size bytes of allocated memory
94
95       typedef  void  (*memcached_free_fn)(memcached_st  *ptr, void *mem, void
96       *context)
97
98              Parameters
99
100ptr -- pointer to an initialized memcached_st struct
101
102mem -- pointer to previously allocated memory
103
104context -- pointer to the user supplied context
105
106       typedef void *(*memcached_calloc_fn)(memcached_st *ptr,  size_t  nelem,
107       const size_t elsize, void *context)
108
109              Parameters
110
111ptr -- pointer to an initialized memcached_st struct
112
113nelem -- number of elements to allocate
114
115elsize -- the number of bytes to allocate per element
116
117context -- pointer to the user supplied context
118
119              Returns
120                     pointer  to  at  least elsize * nelem  bytes of allocated
121                     and zeroed memory
122

DESCRIPTION

124       libmemcached allows you to specify your own  memory  allocators,  opti‐
125       mized for your application. This enables libmemcached to be used inside
126       of applications that have their own malloc implementation.
127
128       memcached_set_memory_allocators() is used to set the memory  allocators
129       used  by  the memcached instance specified by ptr. Please note that you
130       cannot override only one of the memory allocators, you have to  specify
131       a complete new set if you want to override one of them. All of the mem‐
132       ory allocation functions should behave as specified in  the  C99  stan‐
133       dard.  Specify  NULL as all functions to reset them to the default val‐
134       ues.
135
136       memcached_get_memory_allocators() is used to  get  the  currently  used
137       memory allocators by a memcached handle.
138
139       memcached_get_memory_allocators_context()  returns  the void * that was
140       passed in during the call to memcached_set_memory_allocators().
141
142       The first argument to the memory allocator functions is a pointer to  a
143       memcached  structure, the is passed as const and you will need to clone
144       it in order to make use of any operation which would modify it.
145

NOTES

147       In version 0.38 all functions were modified  to  have  a  context  void
148       pointer  passed  to them. This was so that custom allocators could have
149       their own space for memory.
150

RETURN VALUE

152       memcached_set_memory_allocators() returns MEMCACHED_SUCCESS  upon  suc‐
153       cess,  and  MEMCACHED_FAILURE if you don't pass a complete set of func‐
154       tion pointers.
155

SEE ALSO

157       memcached(1) libmemcached(3) memcached_strerror(3)
158
159
160
161
1621.1                              Sep 20, 2021MEMCACHED_SET_MEMORY_ALLOCATORS(3)
Impressum