diff options
| author | iamcheeseman <[email protected]> | 2026-05-08 19:30:44 -0400 |
|---|---|---|
| committer | iamcheeseman <[email protected]> | 2026-05-08 19:30:44 -0400 |
| commit | 5625a8626fe303748b205c80f87035593cf2f561 (patch) | |
| tree | 5e5a5adb6f1265358ae21ec47cd384362345df5a /teensy/mem.h | |
Initial commit
Diffstat (limited to 'teensy/mem.h')
| -rw-r--r-- | teensy/mem.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/teensy/mem.h b/teensy/mem.h new file mode 100644 index 0000000..61f3ee2 --- /dev/null +++ b/teensy/mem.h @@ -0,0 +1,24 @@ +#ifndef MEM_H_ +#define MEM_H_ + +#include <stdlib.h> + +// NOTE: Overrides GLFW allocator +void ty_init_mem(void); +void ty_deinit_mem(void); +void ty_free_temp_allocs(void); +// Temp allocation. Freed at the end of every frame. Do NOT realloc. +void *ty_talloc(size_t size); + +// These mem_* functions handle the case of a bad allocation. No need to check +// for NULL after allocating with these. In debug builds, they will also track +// allocations and report any memory still in use when the program exits. + +void *ty_alloc(size_t size); +void *ty_realloc(void *ptr, size_t new_size); +void ty_free(void *ptr); + +// Returns -1 in release builds. +int ty_alloc_count(void); + +#endif // MEM_H_ |
