b6978178b1
Introduces wrappers around memory allocation functions in `memory.h` that should be used instead of the standard C ones. These never return NULL and, with the exception of `mem_realloc()`, zero-initialize the allocated memory like `calloc()` does. All allocations made with the memory.h API must be deallocated with `mem_free()`. Although standard `free()` will work on some platforms, it's not portable (currently it won't work on Windows). Likewise, `mem_free()` must not be used to free foreign allocations. The standard C allocation functions are now diagnosed as deprecated. They are, however, available with the `libc_` prefix in case interfacing with foreign APIs is required. So far they are only used to implement `memory.h`. Perhaps the most important change is the introduction of the `ALLOC()`, `ALLOC_ARRAY()`, and `ALLOC_FLEX()` macros. They take a type as a parameter, and allocate enough memory with the correct alignment for that type. That includes overaligned types as well. In most circumstances you should prefer to use these macros. See the `memory.h` header for some usage examples. |
||
---|---|---|
.. | ||
texture_loader | ||
animation.c | ||
animation.h | ||
bgm.c | ||
bgm.h | ||
font.c | ||
font.h | ||
iqm.h | ||
material.c | ||
material.h | ||
meson.build | ||
model.c | ||
model.h | ||
postprocess.c | ||
postprocess.h | ||
resource.c | ||
resource.h | ||
sfx.c | ||
sfx.h | ||
sfxbgm_common.c | ||
sfxbgm_common.h | ||
shader_object.c | ||
shader_object.h | ||
shader_program.c | ||
shader_program.h | ||
sprite.c | ||
sprite.h | ||
texture.c | ||
texture.h |