From 063e5c8c7349583b63bc41189576bf77b78772fa Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Fri, 11 Nov 2016 02:07:30 +0000 Subject: [PATCH] Added comment, switch to >= --- gc.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gc.c b/gc.c index 7e2d5ea3..cf2704c0 100644 --- a/gc.c +++ b/gc.c @@ -531,7 +531,11 @@ void *gc_try_alloc(gc_heap * h, int heap_type, size_t size, char *obj, gc_heap *h_passed = h; gc_free_list *f1, *f2, *f3; pthread_mutex_lock(&heap_lock); - if (size <= h->last_alloc_size) { + // Start searching from the last heap page we had a successful + // allocation from, unless the current request is for a smaller + // block in which case there may be available memory closer to + // the start of the heap. + if (size >= h->last_alloc_size) { h = h->next_free; } for (; h; h = h->next) { // All heaps