diff options
author | Timo Teras <timo.teras@iki.fi> | 2010-03-10 20:11:06 +0200 |
---|---|---|
committer | Timo Teras <timo.teras@iki.fi> | 2010-03-10 20:11:06 +0200 |
commit | 0183e33d9a4759764716e771b85e19f7a997b8bd (patch) | |
tree | 7921b52421171899d9df3999625b0f7134148350 /src/heap.c | |
parent | dc34e87746f69994aad893b39ee4cd3dda6e2f7b (diff) | |
download | libtf-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.c | 12 |
1 files changed, 8 insertions, 4 deletions
@@ -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; |