From ee348973b0cb0f6481e4fd6e7494c63167c9759c Mon Sep 17 00:00:00 2001 From: Alexis211 Date: Wed, 7 Apr 2010 11:37:21 +0200 Subject: More work on manager --- src/library/gc/shm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/library/gc/shm.c') diff --git a/src/library/gc/shm.c b/src/library/gc/shm.c index 8077352..7f8609a 100644 --- a/src/library/gc/shm.c +++ b/src/library/gc/shm.c @@ -28,7 +28,7 @@ void* shm_alloc(size_t size) { //go through all blocks, get the one with the closest size struct shm_block *i = blocks, *block = 0; while (i) { - if (i->size >= size && i->is_hole == 1 && i->size < block->size) block = i; + if (i->size >= size && i->is_hole == 1 && (block == 0 || i->size < block->size)) block = i; i = i->next; } if (block == 0) { @@ -57,7 +57,7 @@ static void unify (struct shm_block *b) { if (b->next == 0 || b->is_hole == 0 || b->next->is_hole == 0) return; struct shm_block *n = b->next; b->size += n->size; - n->next->prev = b; + if (n->next != 0) n->next->prev = b; b->next = n->next; free(n); } -- cgit v1.2.3