diff options
Diffstat (limited to 'src/uctx.h')
-rw-r--r-- | src/uctx.h | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -11,6 +11,7 @@ */ #include <libtf/fiber.h> +#include <libtf/memory.h> #include <stdio.h> #include <stdlib.h> @@ -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); } } |