wok on arena
This commit is contained in:
1 parent
ee1878cce7
commit
16664c68b5
5 files changed
+72
No files matched your search
@@ -5,6 +5,27 @@
|
||||
#define internal static
|
||||
#define global static
|
||||
|
||||
// =============================================================================
|
||||
// Units
|
||||
|
||||
#define KB(d) ((uint64)(d) << 10)
|
||||
#define MB(d) ((uint64)(d) << 20)
|
||||
#define GB(d) ((uint64)(d) << 30)
|
||||
|
||||
// =============================================================================
|
||||
// Asserts
|
||||
|
||||
#define StaticAssert(cond, ID) global uint8 GLUE(ID, __LINE__)[(cond) ? 1 : -1]
|
||||
|
||||
// =============================================================================
|
||||
// Helpers
|
||||
|
||||
#define GLUE_(A, B) A##B
|
||||
#define GLUE(A, B) GLUE_(A, B)
|
||||
|
||||
// =============================================================================
|
||||
// Core Types
|
||||
|
||||
typedef uint8_t uint8;
|
||||
typedef uint16_t uint16;
|
||||
typedef uint32_t uint32;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
// =============================================================================
|
||||
// Arena Functions
|
||||
|
||||
internal Arena* arena_alloc_internal()
|
||||
{
|
||||
Arena* arena = NULL;
|
||||
return arena;
|
||||
}
|
||||
|
||||
internal void arena_release(Arena* arena) {}
|
||||
@@ -0,0 +1,39 @@
|
||||
#pragma once
|
||||
|
||||
#define ARENA_HEADER_SIZE 128
|
||||
|
||||
// =============================================================================
|
||||
// Arena Types
|
||||
|
||||
typedef struct Arena Arena;
|
||||
struct Arena
|
||||
{
|
||||
Arena* previous;
|
||||
Arena* current;
|
||||
uint64 base_position;
|
||||
uint64 position;
|
||||
uint64 commit_size;
|
||||
uint64 committed;
|
||||
uint64 reserve_size;
|
||||
uint64 reserved;
|
||||
|
||||
#if BUILD_DEBUG
|
||||
char* alloc_file;
|
||||
int alloc_line;
|
||||
char* name;
|
||||
#endif
|
||||
};
|
||||
StaticAssert(sizeof(Arena) <= ARENA_HEADER_SIZE, arena_header_size_check);
|
||||
|
||||
typedef struct TempArena TempArena;
|
||||
struct TempAren
|
||||
{
|
||||
Arena* arena;
|
||||
uint64 position;
|
||||
};
|
||||
|
||||
// =============================================================================
|
||||
// Arena Functions
|
||||
|
||||
global uint64 arena_default_reserve_size = MB(64);
|
||||
global uint64 arena_default_commit_size = KB(64);
|
||||
@@ -1,5 +1,6 @@
|
||||
// clang-format off
|
||||
#include "core_string.c"
|
||||
#include "core_arena.c"
|
||||
#include "core_entry_point.c"
|
||||
// clang-format on
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include "core_defines.h"
|
||||
|
||||
#include "core.h"
|
||||
#include "core_arena.h"
|
||||
#include "core_string.h"
|
||||
#include "core_entry_point.h"
|
||||
// clang-format on
|
||||
|
||||
Reference in new issue
Block a user