summaryrefslogtreecommitdiff
path: root/src/library/gc
diff options
context:
space:
mode:
authorAlexis211 <alexis211@gmail.com>2010-04-05 16:56:17 +0200
committerAlexis211 <alexis211@gmail.com>2010-04-05 16:56:17 +0200
commit8d94ae49601e0e4023bcdc35191669b2c24f6c96 (patch)
tree64d625ee6aa5a897666be2768d009b2353ba97d9 /src/library/gc
parentb945eafa126d6a17aa8826a405df7d5d4d999008 (diff)
downloadTCE-8d94ae49601e0e4023bcdc35191669b2c24f6c96.tar.gz
TCE-8d94ae49601e0e4023bcdc35191669b2c24f6c96.zip
More work on IPC.
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.c8
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);