FLINT3.7.0-dev

flint_aligned_alloc, flint_aligned_free

Synopsis#include <flint/flint.h>
void * flint_aligned_alloc(size_t alignment, size_t size)source
void flint_aligned_free(void * ptr)source

flint_aligned_alloc allocates size bytes at an address that is a multiple of alignment, which must be a power of two and at least sizeof(ulong); size must be a multiple of alignment (checked only with assertions enabled). Throws on failure. The block must be freed with flint_aligned_free.

By default these use aligned_alloc and free (or _aligned_malloc and _aligned_free on Windows). Where neither is available, and whenever custom memory functions have been installed with __flint_set_memory_functions, they over-allocate with flint_malloc and store the offset of the aligned address in front of it.

Cite this page

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