aboutsummaryrefslogtreecommitdiff
path: root/src/lib/libkogata/user_region.c
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2015-03-14 14:17:03 +0100
committerAlex Auvolat <alex@adnab.me>2015-03-14 14:17:03 +0100
commit4672f514591f0f7110103c4cd898909aef95b635 (patch)
tree59a7edc5fd7b1c9c567ada4ec74afe1ed30d5d15 /src/lib/libkogata/user_region.c
parentf811e0126639c3cc14c285f2e2093d0df1b556af (diff)
downloadkogata-4672f514591f0f7110103c4cd898909aef95b635.tar.gz
kogata-4672f514591f0f7110103c4cd898909aef95b635.zip
Fix region allocator (see changes in region.c!) ; debug spam control.
Diffstat (limited to 'src/lib/libkogata/user_region.c')
-rw-r--r--src/lib/libkogata/user_region.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/libkogata/user_region.c b/src/lib/libkogata/user_region.c
index 516259b..14c0898 100644
--- a/src/lib/libkogata/user_region.c
+++ b/src/lib/libkogata/user_region.c
@@ -56,6 +56,9 @@ static void remove_free_region(descriptor_t *d) {
first_free_region_by_size = d->free.next_by_size;
} else {
for (descriptor_t *i = first_free_region_by_size; i != 0; i = i->free.next_by_size) {
+ if (i->free.first_bigger == d) {
+ i->free.first_bigger = d->free.next_by_size;
+ }
if (i->free.next_by_size == d) {
i->free.next_by_size = d->free.next_by_size;
break;
@@ -337,7 +340,9 @@ void dbg_print_region_info() {
}
dbg_printf("- Free process regions, by size:\n");
for (descriptor_t *d = first_free_region_by_size; d != 0; d = d->free.next_by_size) {
- dbg_printf("| 0x%p - 0x%p\n", d->free.addr, d->free.addr + d->free.size);
+ dbg_printf("| 0x%p - 0x%p ", d->free.addr, d->free.addr + d->free.size);
+ dbg_printf("(0x%p, next in size: 0x%p)\n", d->free.size,
+ (d->free.first_bigger == 0 ? 0 : d->free.first_bigger->free.addr));
ASSERT(d != d->free.next_by_size);
}
dbg_printf("- Used process regions:\n");
@@ -345,7 +350,12 @@ void dbg_print_region_info() {
dbg_printf("| 0x%p - 0x%p %s\n", d->used.i.addr, d->used.i.addr + d->used.i.size, d->used.i.type);
ASSERT(d != d->used.next_by_addr);
}
- dbg_printf("\\\n");
+
+ int nfreerd = 0;
+ for (descriptor_t *i = first_unused_descriptor; i != 0; i = i->unused_descriptor.next)
+ nfreerd++;
+
+ dbg_printf("\\ Free region descriptors: %d (%d)\n", nfreerd, n_unused_descriptors);
mutex_unlock(&ra_mutex);
}