Full rewrite

This commit is contained in:
Ole Morud
2023-06-17 12:14:28 +02:00
committed by Ole Morud
parent e5fa743d85
commit 069f6b11dc
9 changed files with 176 additions and 272 deletions

View File

@@ -1,13 +1,38 @@
## `arena_t arena_new()`
Allocate a new arena.
The underlying memory is allocated with mmap.
`arena_t* arena_new()`
## `void arena_delete(arena_t *a)`
Initializes and returns new arena
Delete memory mapped for arena.
Should only be used with arenas from arena\_new().
`void arena_reset(arena_t *a)`
Free memory allocated in arena
## `arena_t arena_attach(void *ptr, size_t size)`
`void* arena_alloc(arena_t *a, size_t len)`
Attach an arena to an existing memory region.
The arena will not expand the region if space is exceeded.
## `void *arena_detatch(arena_t arena)`
Detach an arena from an existing memory region.
## `void arena_reset(arena_t *a)`
Reset an arena.
## `void *arena_alloc(arena_t *a, size_t len)`
Allocate memory from an arena.
Returns NULL and sets errno on failure.
## `void *arena_calloc(arena_t *a, size_t nmemb, size_t size)`
Allocate and zero memory from an arena.
Returns NULL and sets errno on failure.
Allocate new memory using arena