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/uctx.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/uctx.h') diff --git a/src/uctx.h b/src/uctx.h index 5eca6be..3ec30c4 100644 --- a/src/uctx.h +++ b/src/uctx.h @@ -11,6 +11,7 @@ */ #include +#include #include #include @@ -26,6 +27,7 @@ struct tf_uctx { int *stack_guard; + size_t size; void *alloc; void *current_sp; unsigned int stack_id; @@ -110,7 +112,7 @@ tf_uctx_create_embedded( void *stack, *stack_base; /* Allocate new stack */ - stack_base = malloc(size); + stack_base = tf_bmem_alloc(size); if (stack_base == NULL) return NULL; @@ -127,6 +129,7 @@ tf_uctx_create_embedded( *uctx = (struct tf_uctx) { .stack_guard = stack_guard(stack_base, size), .alloc = stack_base, + .size = size, .current_sp = stack, .stack_id = VALGRIND_STACK_REGISTER(stack_base, stack_base+size), }; @@ -140,7 +143,7 @@ void tf_uctx_destroy(struct tf_uctx *uctx) { if (uctx->alloc != NULL) { VALGRIND_STACK_DEREGISTER(uctx->stack_id); - free(uctx->alloc); + tf_bmem_free(uctx->alloc, uctx->size); } } -- cgit v1.2.3