From 0183e33d9a4759764716e771b85e19f7a997b8bd Mon Sep 17 00:00:00 2001 From: Timo Teras Date: Wed, 10 Mar 2010 20:11:06 +0200 Subject: mem: add mmap allocator use it for heaps and fiber stacks. --- src/heap.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/heap.c') diff --git a/src/heap.c b/src/heap.c index e93abe3..2473a70 100644 --- a/src/heap.c +++ b/src/heap.c @@ -112,12 +112,16 @@ int __tf_heap_grow(struct tf_heap_head *head) { void *item; - if (head->allocated) + if (head->allocated) { + item = tf_bmem_resize(head->item, + head->allocated * sizeof(struct tf_heap_child), + 2 * head->allocated * sizeof(struct tf_heap_child)); head->allocated *= 2; - else - head->allocated = 128; + } else { + head->allocated = 4096 / sizeof(struct tf_heap_child); + item = tf_bmem_alloc(head->allocated * sizeof(struct tf_heap_child)); + } - item = realloc(head->item, head->allocated * sizeof(head->item[0])); if (item == NULL) return -ENOMEM; -- cgit v1.2.3