By default, GMP uses malloc
, realloc
and free
for memory
allocation. If malloc
or realloc
fails, GMP prints a message to
the standard error output and terminates execution.
Some applications might want to allocate memory in other ways, or might not want a fatal error when there is no more memory available. To accomplish this, you can specify alternative memory allocation functions.
This can be done in the Berkeley compatibility library as well as the main GMP library.
NULL
, the corresponding default function is retained.
Be sure to call this function only when there are no active GMP objects allocated using the previous memory functions! Usually, that means that you have to call this function before any other GMP function.
The functions you supply should fit the following declarations:
You can assume that the space at ptr was formerly returned from
allocate_function
or reallocate_function
, for a request for
old_size storage units.
You can assume that the space at ptr was formerly returned from
allocate_function
or reallocate_function
, for a request for
size storage units.
(A storage unit is the unit in which the sizeof
operator returns
the size of an object, normally an 8 bit byte.)
Go to the first, previous, next, last section, table of contents.