Fix miniarena
This commit is contained in:
+11
-11
@@ -8,22 +8,22 @@ struct MArena {
|
||||
U8 *base; // start of buffer
|
||||
U32 first_free; // next alloc point
|
||||
U32 size;
|
||||
S32 checkpoint_level; // level of marenatmp_begin nesting
|
||||
S32 checkpoint_level; // level of marena_temp_begin nesting
|
||||
};
|
||||
|
||||
typedef struct MArenaCheckpoint MArenaCheckpoint;
|
||||
struct MArenaCheckpoint {
|
||||
typedef struct MTemp MTemp;
|
||||
struct MTemp {
|
||||
U32 offset;
|
||||
MArena *arena;
|
||||
};
|
||||
|
||||
#define MARENA_STATIC_INITIALIZER(data) MARENA_INITIALIZER((data), sizeof(data))
|
||||
#define MARENA_INITIALIZER(data, size) {.base = (data), .base = (data), .first_free = 0, .size = (U32)sizeof(data), checkpoint_level = 0}
|
||||
#define MARENA_INITIALIZER(data, size_) {.base = (data), .first_free = 0, .size = (U32)size_, .checkpoint_level = 0}
|
||||
#define MARENA_DEFINE(var_name, size, alignment_) \
|
||||
struct { \
|
||||
_Alignas(alignment_) U8 memory[size]; \
|
||||
} var_name##_arena_memory; \
|
||||
MArena var_name = MARENA_STATIC_INITIALIZER(var_name##_arena_memory.memory)
|
||||
struct { \
|
||||
_Alignas(alignment_) U8 memory[size];\
|
||||
} var_name##_marena_memory; \
|
||||
MArena var_name = MARENA_STATIC_INITIALIZER(var_name##_marena_memory.memory)
|
||||
|
||||
|
||||
|
||||
@@ -35,9 +35,9 @@ static INLINE void marena_init(MArena *arena, void *memory, U32 size)
|
||||
arena->size = size;
|
||||
}
|
||||
|
||||
static INLINE MArenaCheckpoint marenatmp_begin(MArena *arena)
|
||||
static INLINE MTemp marena_temp_begin(MArena *arena)
|
||||
{
|
||||
MArenaCheckpoint checkpoint = {};
|
||||
MTemp checkpoint = {};
|
||||
|
||||
checkpoint.arena = arena;
|
||||
checkpoint.offset = arena->first_free;
|
||||
@@ -46,7 +46,7 @@ static INLINE MArenaCheckpoint marenatmp_begin(MArena *arena)
|
||||
return checkpoint;
|
||||
}
|
||||
|
||||
static INLINE void marenatmp_end(MArenaCheckpoint *state)
|
||||
static INLINE void marena_temp_end(MTemp *state)
|
||||
{
|
||||
MArena *arena = state->arena;
|
||||
Assert(arena->checkpoint_level > 0);
|
||||
|
||||
Reference in New Issue
Block a user