151c586b8Smrg /* mp_set_memory_functions -- Set the allocate, reallocate, and free functions
251c586b8Smrg for use by the mp package.
351c586b8Smrg
451c586b8Smrg Copyright 1991, 1993, 1994, 2000, 2001 Free Software Foundation, Inc.
551c586b8Smrg
651c586b8Smrg This file is part of the GNU MP Library.
751c586b8Smrg
851c586b8Smrg The GNU MP Library is free software; you can redistribute it and/or modify
9*ce543368Smrg it under the terms of either:
10*ce543368Smrg
11*ce543368Smrg * the GNU Lesser General Public License as published by the Free
12*ce543368Smrg Software Foundation; either version 3 of the License, or (at your
1351c586b8Smrg option) any later version.
1451c586b8Smrg
15*ce543368Smrg or
16*ce543368Smrg
17*ce543368Smrg * the GNU General Public License as published by the Free Software
18*ce543368Smrg Foundation; either version 2 of the License, or (at your option) any
19*ce543368Smrg later version.
20*ce543368Smrg
21*ce543368Smrg or both in parallel, as here.
22*ce543368Smrg
2351c586b8Smrg The GNU MP Library is distributed in the hope that it will be useful, but
2451c586b8Smrg WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
25*ce543368Smrg or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
26*ce543368Smrg for more details.
2751c586b8Smrg
28*ce543368Smrg You should have received copies of the GNU General Public License and the
29*ce543368Smrg GNU Lesser General Public License along with the GNU MP Library. If not,
30*ce543368Smrg see https://www.gnu.org/licenses/. */
3151c586b8Smrg
3251c586b8Smrg #include "gmp-impl.h"
3351c586b8Smrg
3451c586b8Smrg void
mp_set_memory_functions(void * (* alloc_func)(size_t),void * (* realloc_func)(void *,size_t,size_t),void (* free_func)(void *,size_t))3551c586b8Smrg mp_set_memory_functions (void *(*alloc_func) (size_t),
3651c586b8Smrg void *(*realloc_func) (void *, size_t, size_t),
37dab47db4Smrg void (*free_func) (void *, size_t)) __GMP_NOTHROW
3851c586b8Smrg {
3951c586b8Smrg if (alloc_func == 0)
4051c586b8Smrg alloc_func = __gmp_default_allocate;
4151c586b8Smrg if (realloc_func == 0)
4251c586b8Smrg realloc_func = __gmp_default_reallocate;
4351c586b8Smrg if (free_func == 0)
4451c586b8Smrg free_func = __gmp_default_free;
4551c586b8Smrg
4651c586b8Smrg __gmp_allocate_func = alloc_func;
4751c586b8Smrg __gmp_reallocate_func = realloc_func;
4851c586b8Smrg __gmp_free_func = free_func;
4951c586b8Smrg }
50