diff options
author | Nicholas Noll <nbnoll@eml.cc> | 2020-04-21 12:38:03 -0700 |
---|---|---|
committer | Nicholas Noll <nbnoll@eml.cc> | 2020-04-21 12:38:03 -0700 |
commit | aa064359cb514251a73b53de3e530fa89f687ab7 (patch) | |
tree | 0e16ab88b16c26dbda88a1349adf61331521ac60 /include | |
parent | 06f60ae1b3c7d11092a5433186360fcbb1221309 (diff) |
feat: added allocator interface to allow for flexible library interfaces
Diffstat (limited to 'include')
-rw-r--r-- | include/libn.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/include/libn.h b/include/libn.h index 64e2e70..74e230e 100644 --- a/include/libn.h +++ b/include/libn.h @@ -48,6 +48,18 @@ void* bufgrow(void*, vlong, vlong); void _bufpop(void*, int, vlong); // ----------------------------------------------------------------------------- +// Memory allocation + +// TODO: Think about interface here. +typedef struct Allocator { + void *(*alloc)(ulong size); + void *(*realloc)(void *ptr, ulong size); + void (*free)(void *ptr); +} Allocator; + +static Allocator mem·sys = { .alloc = &malloc, .realloc = &realloc, .free = &free}; + +// ----------------------------------------------------------------------------- // Co-routines typedef struct Coro Coro; |