From 20d67907c95265356b51dbdce8ecc0c1ede9e66b Mon Sep 17 00:00:00 2001 From: Tanaka Akira Date: Thu, 15 Apr 1999 18:11:42 +0000 Subject: zsh-3.1.5-pws-5 --- Src/mem.c | 54 ++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 14 deletions(-) (limited to 'Src/mem.c') diff --git a/Src/mem.c b/Src/mem.c index 32822ab8c..703920215 100644 --- a/Src/mem.c +++ b/Src/mem.c @@ -129,25 +129,51 @@ global_permalloc(void) return luh; } -/* heappush saves the current heap state using this structure */ +/* list of zsh heap */ -struct heapstack { - struct heapstack *next; /* next one in list for this heap */ - size_t used; -}; +static Heap heaps; -/* A zsh heap. */ +/* Use new heaps from now on. This returns the old heap-list. */ -struct heap { - struct heap *next; /* next one */ - size_t used; /* bytes used from the heap */ - struct heapstack *sp; /* used by pushheap() to save the value used */ -#define arena(X) ((char *) (X) + sizeof(struct heap)) -}; +/**/ +Heap +new_heaps(void) +{ + Heap h = heaps; -/* list of zsh heap */ + heaps = NULL; -static Heap heaps; + return h; +} + +/* Re-install the old heaps again, freeing the new ones. */ + +/**/ +void +old_heaps(Heap old) +{ + Heap h, n; + + for (h = heaps; h; h = n) { + n = h->next; + DPUTS(h->sp, "BUG: old_heaps() with pushed heaps"); + zfree(h, sizeof(*h)); + } + heaps = old; +} + +/* Temporarily switch to other heaps (or back again). */ + +/**/ +Heap +switch_heaps(Heap new) +{ + Heap h = heaps; + + heaps = new; + + return h; +} /* save states of zsh heaps */ -- cgit 1.4.1