diff --git a/src/util.h b/src/util.h index fdc71f2..60087f1 100644 --- a/src/util.h +++ b/src/util.h @@ -41,6 +41,8 @@ char* arenaCopyCStr(memory_arena* arena, const char* input, u32 max_len = MAX_NAME_LENGTH); +#define UTIL_ALLOC(count, type) (type*) utilAllocate(count, sizeof(type)) +void* utilAllocate(u32 count, u32 type_size); char* utilAllocateCStr(const char* str, u32 max_len = 256); void utilSafeFree(void* p); @@ -120,6 +122,14 @@ arenaCopyCStr(memory_arena* arena, const char* input, u32 max_len) return out; } +void* +utilAllocate(u32 count, u32 type_size) +{ + void* out = std::calloc(count, type_size); + assert(out != nullptr); + return out; +} + char* utilAllocateCStr(const char* str, u32 max_len) {