#include <base.h>
Data Fields | |
void *(* | alloc )(void *opaque, size_t nmemb, size_t size) |
Pointer to a custom memory allocation function. | |
void(* | free )(void *opaque, void *ptr) |
Pointer to a custom memory freeing function. | |
void * | opaque |
Pointer passed to .alloc() and .free(). |
A pointer to lzma_allocator may be passed via lzma_stream structure to liblzma, and some advanced functions take a pointer to lzma_allocator as a separate function argument. The library will use the functions specified in lzma_allocator for memory handling instead of the default malloc() and free(). C++ users should note that the custom memory handling functions must not throw exceptions.
liblzma doesn't make an internal copy of lzma_allocator. Thus, it is OK to change these function pointers in the middle of the coding process, but obviously it must be done carefully to make sure that the replacement `free' can deallocate memory allocated by the earlier `alloc' function(s).
void*( * lzma_allocator::alloc)(void *opaque, size_t nmemb, size_t size) |
Pointer to a custom memory allocation function.
If you don't want a custom allocator, but still want custom free(), set this to NULL and liblzma will use the standard malloc().
opaque | lzma_allocator.opaque (see below) | |
nmemb | Number of elements like in calloc(). liblzma will always set nmemb to 1, so it is safe to ignore nmemb in a custom allocator if you like. The nmemb argument exists only for compatibility with zlib and libbzip2. | |
size | Size of an element in bytes. liblzma never sets this to zero. |
void( * lzma_allocator::free)(void *opaque, void *ptr) |
Pointer to a custom memory freeing function.
If you don't want a custom freeing function, but still want a custom allocator, set this to NULL and liblzma will use the standard free().
opaque | lzma_allocator.opaque (see below) | |
ptr | Pointer returned by lzma_allocator.alloc(), or when it is set to NULL, a pointer returned by the standard malloc(). |
Referenced by lzma_free().
void* lzma_allocator::opaque |
Pointer passed to .alloc() and .free().
opaque is passed as the first argument to lzma_allocator.alloc() and lzma_allocator.free(). This intended to ease implementing custom memory allocation functions for use with liblzma.
If you don't need this, you should set this to NULL.
Referenced by lzma_free().