summaryrefslogtreecommitdiffstats
path: root/src/uctx.h
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/uctx.h
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/uctx.h')
-rw-r--r--src/uctx.h7
1 files changed, 5 insertions, 2 deletions
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 <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);
}
}