Compare commits
2 Commits
b8db582098
...
7948d3fd1a
Author | SHA1 | Date | |
---|---|---|---|
7948d3fd1a | |||
1094a9fefb |
@@ -6,6 +6,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#ifndef DEFAULT_ALIGNMENT
|
#ifndef DEFAULT_ALIGNMENT
|
||||||
|
// Why 2 * sizeof(void *) instead of sizeof(void *)
|
||||||
|
// https://handmade.network/forums/t/6860-alignment_arena_allocator
|
||||||
#define DEFAULT_ALIGNMENT (2 * sizeof(void *))
|
#define DEFAULT_ALIGNMENT (2 * sizeof(void *))
|
||||||
#endif /* ifndef DEFAULT_ALIGNMENT */
|
#endif /* ifndef DEFAULT_ALIGNMENT */
|
||||||
|
|
||||||
@@ -47,12 +49,14 @@ bool mem_arena_init(Arena **arena, u64 base_capacity) {
|
|||||||
|
|
||||||
arena_ptr->active_arena = (BaseArena *)malloc(sizeof(BaseArena));
|
arena_ptr->active_arena = (BaseArena *)malloc(sizeof(BaseArena));
|
||||||
if (!(arena_ptr->active_arena)) {
|
if (!(arena_ptr->active_arena)) {
|
||||||
|
mem_arena_free(arena);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(arena_ptr->active_arena, 0, sizeof(BaseArena));
|
memset(arena_ptr->active_arena, 0, sizeof(BaseArena));
|
||||||
|
|
||||||
if (!base_arena_init(arena_ptr->active_arena, base_capacity)) {
|
if (!base_arena_init(arena_ptr->active_arena, base_capacity)) {
|
||||||
|
mem_arena_free(arena);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user