Proper memory commitment
This commit is contained in:
+7
-3
@@ -7,6 +7,7 @@ typedef U32 ArenaFlags; // no flags defined yets
|
||||
typedef struct ArenaParams ArenaParams;
|
||||
struct ArenaParams {
|
||||
U32 size;
|
||||
U32 commit_size;
|
||||
ArenaFlags flags; // No flags defined yet
|
||||
};
|
||||
|
||||
@@ -14,15 +15,17 @@ typedef struct MemoryBlock MemoryBlock;
|
||||
struct MemoryBlock {
|
||||
U8 *base;
|
||||
U32 size;
|
||||
U32 base_pos; // absolute position of base relative to the first linked arena
|
||||
U32 pos; // start of next allocation
|
||||
U32 base_pos; // absolute position of base relative to the first linked arena
|
||||
U32 committed_pos;
|
||||
MemoryBlock *prev;
|
||||
};
|
||||
|
||||
typedef struct Arena Arena;
|
||||
struct Arena {
|
||||
MemoryBlock *current;
|
||||
U32 requested_size;
|
||||
U32 block_size;
|
||||
U32 commit_size;
|
||||
ArenaFlags flags;
|
||||
S32 checkpoint_level;
|
||||
};
|
||||
@@ -50,7 +53,8 @@ ArenaCheckPoint arena_temp_begin(Arena *arena);
|
||||
void arena_temp_end(ArenaCheckPoint *checkpoint);
|
||||
void arena_pop_to(Arena *arena, U32 abs_pos);
|
||||
void arena_reset(Arena *arena);
|
||||
MemoryBlock *memoryblock_allocate(size_t size);
|
||||
MemoryBlock *memoryblock_allocate(size_t size, size_t commit_size);
|
||||
|
||||
|
||||
static INLINE U32 memoryblock_available(const MemoryBlock *block)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user