FLINT3.7.0-dev

__flint_set_memory_functions, __flint_get_memory_functions

Synopsis#include <flint/flint.h>
void __flint_set_memory_functions(void * (* alloc_func)(size_t), void * (* calloc_func)(size_t, size_t), void * (* realloc_func)(void *, size_t), void (* free_func)(void *))source
void __flint_get_memory_functions(void * (** alloc_func)(size_t), void * (** calloc_func)(size_t, size_t), void * (** realloc_func)(void *, size_t), void (** free_func)(void *))source

Install or retrieve the functions called by flint_malloc, flint_calloc, flint_realloc and flint_free. Installing new functions also makes flint_aligned_alloc and flint_aligned_free use the new alloc_func and free_func (with over-allocation).

The functions must be installed before FLINT allocates anything, or memory allocated by the old functions will be passed to the new free_func. The installed functions may return NULL on failure; flint_malloc then throws; free_func must accept NULL. GMP and MPFR use their own memory functions, which are set separately with mp_set_memory_functions; FLINT never mixes the two. See Custom allocators for the precise requirements.

Cite this page

The FLINT team, “__flint_set_memory_functions, __flint_get_memory_functions (flint.h),” FLINT: Fast Library for Number Theory, documentation, version 3.7.0-dev, 2026. https://flintlib.org/doc/flint/__flint_set_memory_functions.html (generated 2026-10-20).