diff options
author | Kevin Ryde <user42@zip.com.au> | 2000-04-12 01:53:58 +0200 |
---|---|---|
committer | Kevin Ryde <user42@zip.com.au> | 2000-04-12 01:53:58 +0200 |
commit | d5da4b38e3292e8f3a8df6af1dbdcc1489b7adc1 (patch) | |
tree | fbdebf3062b8a96c3fe423c74a64e2b12a28f87a /stack-alloc.c | |
parent | ea70511dc4851edc96df193b4535987ffa783925 (diff) | |
download | gmp-d5da4b38e3292e8f3a8df6af1dbdcc1489b7adc1.tar.gz |
* stack-alloc.c: Use _mp_allocate_func, not malloc.
Diffstat (limited to 'stack-alloc.c')
-rw-r--r-- | stack-alloc.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/stack-alloc.c b/stack-alloc.c index aecbb0a03..80966c208 100644 --- a/stack-alloc.c +++ b/stack-alloc.c @@ -22,9 +22,17 @@ MA 02111-1307, USA. */ #include "stack-alloc.h" +#define __need_size_t +#include <stddef.h> +#undef __need_size_t + +/* gmp-impl.h and stack-alloc.h conflict when not USE_STACK_ALLOC, so these + declarations are copied here */ +extern void * (*_mp_allocate_func) (size_t); +extern void (*_mp_free_func) (void *, size_t); + typedef struct tmp_stack tmp_stack; -void *malloc (); static unsigned long max_total_allocation = 0; static unsigned long current_total_allocation = 0; @@ -69,7 +77,7 @@ __tmp_alloc (size) current_total_allocation = max_total_allocation; } - chunk = malloc (chunk_size); + chunk = (*_mp_allocate_func) (chunk_size); header = chunk; header->end = (char *) chunk + chunk_size; header->alloc_point = (char *) chunk + HSIZ; @@ -104,7 +112,7 @@ __tmp_free (mark) tmp = current; current = tmp->prev; current_total_allocation -= (((char *) (tmp->end) - (char *) tmp) - HSIZ); - free (tmp); + (*_mp_free_func) (tmp, (char *) tmp->end - (char *) tmp); } current->alloc_point = mark->alloc_point; } |