This fixes a nasty bug that manifests on windows when building without
precompiled headers. util/stringops.h used to silently replace strdup
with a macro that's compatible with mem_free(). This header would
typically be included everywhere due to PCH, but without it the strdup
from libc would sometimes be in scope. On most platforms mem_free() is
equivalent to free(), but not on windows, because we have to use
_aligned_free() there. Attempting to mem_free() the result of a libc
strdup() would segfault in such a configuration.
Avoid the footgun by banning strdup() entirely. Maybe redefining libc
names isn't such a great idea, who knew?
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.
* initial commit (basic structure, does not compile)
* it compiles now
* moving some stuff around
* move spells/nonspells over to their own files, and retab the whole directory
* retab meson file (oops)
* newline shuffling
* clean up some imports, move functions to spellcards
* Update src/stages/stage5/background_anim.c
Co-authored-by: Andrei Alexeyev <akari@taisei-project.org>
* Apply suggestions from code review
Co-authored-by: Andrei Alexeyev <akari@taisei-project.org>
* code review changes
* change cloud_common to spawn_cloud
* move explosion survival to spells
* add missing timeline imports (oops)
* add missing comma
Co-authored-by: Andrei Alexeyev <akari@taisei-project.org>
* basic stage 6 structure (nothing here yet)
* it compiles and runs (needs testing)
* reindent
* missing import
* fix baryons
* import cleanups
* moving spells from elly.c to their spellcard sources
* code review changes, and some additional cleanup
* more PR changes, removing more dead code
* clean up some imports, move functions to spellcards
* remove dual initalization