.\" Man page generated from reStructuredText. . . .nr rst2man-indent-level 0 . .de1 rstReportMargin \\$1 \\n[an-margin] level \\n[rst2man-indent-level] level margin: \\n[rst2man-indent\\n[rst2man-indent-level]] - \\n[rst2man-indent0] \\n[rst2man-indent1] \\n[rst2man-indent2] .. .de1 INDENT .\" .rstReportMargin pre: . RS \\$1 . nr rst2man-indent\\n[rst2man-indent-level] \\n[an-margin] . nr rst2man-indent-level +1 .\" .rstReportMargin post: .. .de UNINDENT . RE .\" indent \\n[an-margin] .\" old: \\n[rst2man-indent\\n[rst2man-indent-level]] .nr rst2man-indent-level -1 .\" new: \\n[rst2man-indent\\n[rst2man-indent-level]] .in \\n[rst2man-indent\\n[rst2man-indent-level]]u .. .TH "MEMCACHED_GET_MEMORY_ALLOCATORS" "3" "Mar 11, 2024" "1.1" "libmemcached-awesome" .SH NAME memcached_get_memory_allocators \- libmemcached Documentation .sp Manage memory allocator functions .SH SYNOPSIS .INDENT 0.0 .TP .B #include Compile and link with \-lmemcached .UNINDENT .INDENT 0.0 .TP .B \fI\%memcached_return_t\fP memcached_set_memory_allocators(\fI\%memcached_st\fP *ptr, \fI\%memcached_malloc_fn\fP mem_malloc, \fI\%memcached_free_fn\fP mem_free, \fI\%memcached_realloc_fn\fP mem_realloc, \fI\%memcached_calloc_fn\fP mem_calloc, void *context) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBptr\fP \-\- pointer to an initialized \fI\%memcached_st\fP struct .IP \(bu 2 \fBmem_malloc\fP \-\- pointer to a \fI\%memcached_malloc_fn\fP callback .IP \(bu 2 \fBmem_free\fP \-\- pointer to a \fI\%memcached_free_fn\fP callback .IP \(bu 2 \fBmem_realloc\fP \-\- pointer to a \fI\%memcached_realloc_fn\fP callback .IP \(bu 2 \fBmem_calloc\fP \-\- pointer to a \fI\%memcached_calloc_fn\fP callback .IP \(bu 2 \fBcontext\fP \-\- pointer to a user supplied context .UNINDENT .TP .B Returns \fI\%memcached_return_t\fP indicating success .UNINDENT .UNINDENT .INDENT 0.0 .TP .B void memcached_get_memory_allocators(\fI\%memcached_st\fP *ptr, \fI\%memcached_malloc_fn\fP *mem_malloc, \fI\%memcached_free_fn\fP *mem_free, \fI\%memcached_realloc_fn\fP *mem_realloc, \fI\%memcached_calloc_fn\fP *mem_calloc) .INDENT 7.0 .TP .B Parameters .INDENT 7.0 .IP \(bu 2 \fBptr\fP \-\- pointer to an initialized \fI\%memcached_st\fP struct .IP \(bu 2 \fBmem_malloc\fP \-\- pointer to store the address of the \fI\%memcached_malloc_fn\fP callback .IP \(bu 2 \fBmem_free\fP \-\- pointer to store the address of the \fI\%memcached_free_fn\fP callback .IP \(bu 2 \fBmem_realloc\fP \-\- pointer to store the address of the \fI\%memcached_realloc_fn\fP callback .IP \(bu 2 \fBmem_calloc\fP \-\- pointer to store the address of the \fI\%memcached_calloc_fn\fP callback .UNINDENT .UNINDENT .UNINDENT .INDENT 0.0 .TP .B void *memcached_get_memory_allocators_context(const \fI\%memcached_st\fP *ptr) .INDENT 7.0 .TP .B Parameters \fBptr\fP \-\- pointer to an initialized \fI\%memcached_st\fP struct .TP .B Returns pointer to the user supplied context .UNINDENT .UNINDENT .INDENT 0.0 .TP .B typedef void *(*memcached_malloc_fn)(\fI\%memcached_st\fP *ptr, const size_t size, void *context) .INDENT 7.0 .TP .B Param ptr pointer to an initialized \fI\%memcached_st\fP struct .TP .B Param size the number of bytes to allocate .TP .B Param context pointer to the user supplied context .TP .B Returns pointer to at least \fBsize\fP bytes of allocated memory .UNINDENT .UNINDENT .INDENT 0.0 .TP .B typedef void *(*memcached_realloc_fn)(\fI\%memcached_st\fP *ptr, void *mem, const size_t size, void *context) .INDENT 7.0 .TP .B Param ptr pointer to an initialized \fI\%memcached_st\fP struct .TP .B Param mem pointer to previously allocated memory .TP .B Param size the number of bytes to allocate .TP .B Param context pointer to the user supplied context .TP .B Returns pointer to at least \fBsize\fP bytes of allocated memory .UNINDENT .UNINDENT .INDENT 0.0 .TP .B typedef void (*memcached_free_fn)(\fI\%memcached_st\fP *ptr, void *mem, void *context) .INDENT 7.0 .TP .B Param ptr pointer to an initialized \fI\%memcached_st\fP struct .TP .B Param mem pointer to previously allocated memory .TP .B Param context pointer to the user supplied context .UNINDENT .UNINDENT .INDENT 0.0 .TP .B typedef void *(*memcached_calloc_fn)(\fI\%memcached_st\fP *ptr, size_t nelem, const size_t elsize, void *context) .INDENT 7.0 .TP .B Param ptr pointer to an initialized \fI\%memcached_st\fP struct .TP .B Param nelem number of elements to allocate .TP .B Param elsize the number of bytes to allocate per element .TP .B Param context pointer to the user supplied context .TP .B Returns pointer to at least \fBelsize\fP * \fBnelem\fP bytes of allocated and zeroed memory .UNINDENT .UNINDENT .SH DESCRIPTION .sp \fBlibmemcached\fP allows you to specify your own memory allocators, optimized for your application. This enables libmemcached to be used inside of applications that have their own malloc implementation. .sp \fI\%memcached_set_memory_allocators()\fP is used to set the memory allocators used by the memcached instance specified by ptr. Please note that you cannot override only one of the memory allocators, you have to specify a complete new set if you want to override one of them. All of the memory allocation functions should behave as specified in the C99 standard. Specify NULL as all functions to reset them to the default values. .sp \fI\%memcached_get_memory_allocators()\fP is used to get the currently used memory allocators by a memcached handle. .sp \fI\%memcached_get_memory_allocators_context()\fP returns the void * that was passed in during the call to \fI\%memcached_set_memory_allocators()\fP\&. .sp The first argument to the memory allocator functions is a pointer to a memcached structure, the is passed as const and you will need to clone it in order to make use of any operation which would modify it. .SH NOTES .sp In version 0.38 all functions were modified to have a context void pointer passed to them. This was so that custom allocators could have their own space for memory. .SH RETURN VALUE .sp \fI\%memcached_set_memory_allocators()\fP returns \fI\%MEMCACHED_SUCCESS\fP upon success, and \fI\%MEMCACHED_FAILURE\fP if you don\(aqt pass a complete set of function pointers. .SH SEE ALSO .sp \fBmemcached(1)\fP \fBlibmemcached(3)\fP \fBmemcached_strerror(3)\fP .\" Generated by docutils manpage writer. .