FLINT3.7.0-dev

TMP_INIT, TMP_START, TMP_ALLOC, TMP_ARRAY_ALLOC, TMP_END

Synopsis#include <flint/flint.h>
TMP_INITsource
TMP_STARTsource
TMP_ALLOC(size)source
TMP_ARRAY_ALLOC(n, T)source
TMP_ENDsource

Temporary allocation within one function. TMP_INIT goes with the variable declarations and TMP_START before the first TMP_ALLOC. TMP_ALLOC(size) returns size bytes, taken from the stack with alloca if size is at most 8192 and from flint_malloc otherwise; TMP_ARRAY_ALLOC(n, T) returns an array of n objects of type T. TMP_END frees all blocks obtained since TMP_START.

With assertions enabled, all blocks come from flint_malloc, so that memory checkers see them. Each TMP_ALLOC uses a little stack space even for large blocks, and stack blocks are only released when the function returns, so do not use TMP_ALLOC in a loop or in a recursive function with unbounded depth. The guide Memory management has an example.

Cite this page

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