diff options
author | Alexis211 <alexis211@gmail.com> | 2010-04-07 11:37:21 +0200 |
---|---|---|
committer | Alexis211 <alexis211@gmail.com> | 2010-04-07 11:37:21 +0200 |
commit | ee348973b0cb0f6481e4fd6e7494c63167c9759c (patch) | |
tree | a9f1cd82703aaeeefbf4cf449203881cfcafc0a5 /src/library/gc/shm.c | |
parent | ca4f5906f284e60a7a59ca7450e3e09c4f9356e5 (diff) | |
download | TCE-ee348973b0cb0f6481e4fd6e7494c63167c9759c.tar.gz TCE-ee348973b0cb0f6481e4fd6e7494c63167c9759c.zip |
More work on manager
Diffstat (limited to 'src/library/gc/shm.c')
-rw-r--r-- | src/library/gc/shm.c | 4 |
1 files changed, 2 insertions, 2 deletions
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); } |