From 33ec971c33714ff469a481d1409aa9330e043224 Mon Sep 17 00:00:00 2001 From: Sven Wischnowsky Date: Wed, 7 Mar 2001 12:58:40 +0000 Subject: two optimisations --- Src/mem.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'Src/mem.c') diff --git a/Src/mem.c b/Src/mem.c index 5c995c634..9f88dddaa 100644 --- a/Src/mem.c +++ b/Src/mem.c @@ -105,7 +105,8 @@ union mem_align { static Heap heaps; -/* first heap with free space, not always correct */ +/* a heap with free space, not always correct (it will be the last heap + * if that was newly allocated but it may also be another one) */ static Heap fheap; @@ -297,7 +298,8 @@ zhalloc(size_t size) /* find a heap with enough free space */ - for (h = (fheap ? fheap : heaps); h; h = h->next) { + for (h = ((fheap && HEAP_ARENA_SIZE >= (size + fheap->used)) ? fheap : heaps); + h; h = h->next) { if (HEAP_ARENA_SIZE >= (n = size + h->used)) { void *ret; @@ -364,7 +366,7 @@ zhalloc(size_t size) hp->next = h; else heaps = h; - fheap = NULL; + fheap = h; unqueue_signals(); return arena(h); -- cgit v1.2.3