diff options
author | Tanaka Akira <akr@users.sourceforge.net> | 1999-04-15 18:11:42 +0000 |
---|---|---|
committer | Tanaka Akira <akr@users.sourceforge.net> | 1999-04-15 18:11:42 +0000 |
commit | 20d67907c95265356b51dbdce8ecc0c1ede9e66b (patch) | |
tree | 69b0777db02f96555b3a0587cd630025062a7f09 /Src/mem.c | |
parent | 2a5a899a55fd2bce10efd01c75a4bec5285aa46c (diff) | |
download | zsh-20d67907c95265356b51dbdce8ecc0c1ede9e66b.tar.gz zsh-20d67907c95265356b51dbdce8ecc0c1ede9e66b.tar.xz zsh-20d67907c95265356b51dbdce8ecc0c1ede9e66b.zip |
zsh-3.1.5-pws-5 zsh-3.1.5-pws-5
Diffstat (limited to 'Src/mem.c')
-rw-r--r-- | Src/mem.c | 54 |
1 files changed, 40 insertions, 14 deletions
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 */ |