[ruby/prism] Document xallocator functions

https://github.com/ruby/prism/commit/ee1a4acacd
This commit is contained in:
Kevin Newton 2024-03-04 11:34:53 -05:00 committed by git
parent b95e2cdca7
commit c0a34a6c8c

View File

@ -126,9 +126,12 @@
#endif
/**
* If you build prism with a custom allocator, configure it with "-D PRISM_XALLOCATOR"
* to use your own allocator that defines xmalloc, xrealloc, xcalloc, and xfree.
* For example, your `custom_allocator.h` file could look like this:
* If you build prism with a custom allocator, configure it with
* "-D PRISM_XALLOCATOR" to use your own allocator that defines xmalloc,
* xrealloc, xcalloc, and xfree.
*
* For example, your `prism_xallocator.h` file could look like this:
*
* ```
* #ifndef PRISM_XALLOCATOR_H
* #define PRISM_XALLOCATOR_H
@ -140,12 +143,31 @@
* ```
*/
#ifdef PRISM_XALLOCATOR
# include "prism_xallocator.h"
#include "prism_xallocator.h"
#else
# define xmalloc malloc
# define xrealloc realloc
# define xcalloc calloc
# define xfree free
/**
* The malloc function that should be used. This can be overriden with the
* PRISM_XALLOCATOR define.
*/
#define xmalloc malloc
/**
* The realloc function that should be used. This can be overriden with the
* PRISM_XALLOCATOR define.
*/
#define xrealloc realloc
/**
* The calloc function that should be used. This can be overriden with the
* PRISM_XALLOCATOR define.
*/
#define xcalloc calloc
/**
* The free function that should be used. This can be overriden with the
* PRISM_XALLOCATOR define.
*/
#define xfree free
#endif
#endif