From fd8128d9b84e362abdbd05fafe252421edee8ab2 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Mon, 10 Nov 2025 23:50:41 +0100 Subject: Redesign with sbrk(2) So far, tinyalloc was designed for a static heap area, failing to allocate whenever the end boundary was reached. Unfortunately, this design was too limiting if the same library were to be used for WebAssembly applications, where interpreters are required to implement the current_memory and grow_memory operators. [1] Whereas the former returns the number of currently allocated pages by the interpreter (64 KiB being the standard page size), the latter must increase that number by the number of pages required by the caller, but without exceeding the maximum limit imposed by the application developer. Since WebAssembly's grow_memory is usually converted to sbrk(2) by implementations, tinyalloc now makes use of this traditional syscall to achieve the desired effect. [1]: https://www.w3.org/TR/2019/REC-wasm-core-1-20191205/#-hrefsyntax-instr-memorymathsfmemorygrow --- tinyalloc.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'tinyalloc.h') diff --git a/tinyalloc.h b/tinyalloc.h index c845eea..329ff89 100644 --- a/tinyalloc.h +++ b/tinyalloc.h @@ -5,7 +5,7 @@ extern "C" { #include #include -bool ta_init(void *base, const void *limit, const size_t heap_blocks, const size_t split_thresh, const size_t alignment); +bool ta_init(const size_t heap_blocks, const size_t split_thresh, const size_t alignment); void *ta_alloc(size_t num); void *ta_realloc(void *ptr, size_t n); void *ta_calloc(size_t num, size_t size); @@ -14,7 +14,6 @@ bool ta_free(void *ptr); size_t ta_num_free(); size_t ta_num_used(); size_t ta_num_fresh(); -bool ta_check(); #ifdef __cplusplus } -- cgit v1.2.3