about summary refs log tree commit diff
path: root/Src/mem.c
diff options
context:
space:
mode:
authorSven Wischnowsky <wischnow@users.sourceforge.net>2001-03-07 12:58:40 +0000
committerSven Wischnowsky <wischnow@users.sourceforge.net>2001-03-07 12:58:40 +0000
commit33ec971c33714ff469a481d1409aa9330e043224 (patch)
tree182f1ecce434561b5f12ef6eb8e7dde52bebd282 /Src/mem.c
parent8c978c4006683e8e3549116b2960c660ff04c225 (diff)
downloadzsh-33ec971c33714ff469a481d1409aa9330e043224.tar.gz
zsh-33ec971c33714ff469a481d1409aa9330e043224.tar.xz
zsh-33ec971c33714ff469a481d1409aa9330e043224.zip
two optimisations
Diffstat (limited to 'Src/mem.c')
-rw-r--r--Src/mem.c8
1 files changed, 5 insertions, 3 deletions
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);