Wrote value, chunk, memory sections, tested value

chunk and memory remain untested for now
This commit is contained in:
2024-08-13 23:42:14 +10:00
parent 190294e5d9
commit e6ad46f1ff
11 changed files with 204 additions and 10 deletions

14
source/toy_memory.h Normal file
View File

@@ -0,0 +1,14 @@
#pragma once
#include "toy_common.h"
#define TOY_GROW_CAPACITY(capacity) \
((capacity) < 8 ? 8 : (capacity) * 2)
#define TOY_GROW_ARRAY(type, pointer, oldSize, newSize) \
(type*)Toy_reallocate(pointer, sizeof(type)*oldSize, sizeof(type)*newSize)
#define TOY_FREE_ARRAY(type, pointer, oldSize) \
(type*)Toy_reallocate(pointer, sizeof(type)*oldSize, 0)
TOY_API void* Toy_reallocate(void* pointer, size_t oldSize, size_t newSize);