summaryrefslogtreecommitdiffstats
path: root/src/heap.c
diff options
context:
space:
mode:
authorTimo Teras <timo.teras@iki.fi>2010-03-10 20:11:06 +0200
committerTimo Teras <timo.teras@iki.fi>2010-03-10 20:11:06 +0200
commit0183e33d9a4759764716e771b85e19f7a997b8bd (patch)
tree7921b52421171899d9df3999625b0f7134148350 /src/heap.c
parentdc34e87746f69994aad893b39ee4cd3dda6e2f7b (diff)
downloadlibtf-0183e33d9a4759764716e771b85e19f7a997b8bd.tar.bz2
libtf-0183e33d9a4759764716e771b85e19f7a997b8bd.tar.xz
mem: add mmap allocator
use it for heaps and fiber stacks.
Diffstat (limited to 'src/heap.c')
-rw-r--r--src/heap.c12
1 files changed, 8 insertions, 4 deletions
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;