diff options
Diffstat (limited to 'src/library/gc')
-rw-r--r-- | src/library/gc/server.c (renamed from src/library/gc/object.c) | 9 | ||||
-rw-r--r-- | src/library/gc/shm.c | 8 |
2 files changed, 13 insertions, 4 deletions
diff --git a/src/library/gc/object.c b/src/library/gc/server.c index 87dafd8..9fd1616 100644 --- a/src/library/gc/object.c +++ b/src/library/gc/server.c @@ -109,6 +109,15 @@ Server *srv_create() { return s; } +Server *srv_get(int descriptor) { + Server *s = servers; + while (s) { + if (s->id == descriptor) return s; + s = s->next; + } + return 0; +} + void srv_delete(Server* s) { //remove s from servers if (servers == s) { diff --git a/src/library/gc/shm.c b/src/library/gc/shm.c index 9e19533..8077352 100644 --- a/src/library/gc/shm.c +++ b/src/library/gc/shm.c @@ -26,10 +26,10 @@ void* shm_alloc(size_t size) { if (blocks == 0) shm_init(); if (size & 0xFFF) size = (size & 0xFFFFF000) + 0x1000; //go through all blocks, get the one with the closest size - struct shm_block *block = blocks; - while (block) { - if (block->size >= size) break; - block = block->next; + struct shm_block *i = blocks, *block = 0; + while (i) { + if (i->size >= size && i->is_hole == 1 && i->size < block->size) block = i; + i = i->next; } if (block == 0) { mutex_unlock(&tMutex); |