mirror of
https://github.com/Kaehvaman/OAIP.git
synced 2025-01-18 08:39:11 +04:00
add ArenaDestroy
This commit is contained in:
parent
84cb7fba0c
commit
13072246fa
@ -60,5 +60,16 @@ void* ArenaAlloc(Arena* arena, size_t size)
|
||||
Arena ArenaInit(size_t buffer_size)
|
||||
{
|
||||
void* buffer = SafeMalloc(buffer_size);
|
||||
return (Arena) { buffer, buffer_size, (uintptr_t)buffer };
|
||||
return (Arena) {
|
||||
.buffer = buffer,
|
||||
.size = buffer_size,
|
||||
.offset_ptr = (uintptr_t)buffer
|
||||
};
|
||||
}
|
||||
|
||||
void ArenaDestroy(Arena* arena)
|
||||
{
|
||||
free(arena->buffer);
|
||||
arena->offset_ptr = NULL;
|
||||
arena->size = 0;
|
||||
}
|
@ -18,3 +18,4 @@ typedef struct {
|
||||
Arena ArenaInit(size_t buffer_size);
|
||||
void* ArenaAlloc(Arena* arena, size_t size);
|
||||
void* ArenaAllocAligned(Arena* arena, size_t size, size_t alignment);
|
||||
void ArenaDestroy(Arena* arena);
|
Loading…
Reference in New Issue
Block a user