Files
magic/utils
Darryl L. Miles f173c0ebda SUPPORT_DIRECT_MALLOC and SUPPORT_REMOVE_MALLOC_LEGACY
This supports three build modes:

No additional -D options, default legacy mode

-DSUPPORT_DIRECT_MALLOC, magic will use direct calls to libc malloc/free
 and will leave in place the symbols now renamed as mallocMagicLegacy()
 freeMagicLegacy() and callocMagicLegacy().

-DSUPPORT_DIRECT_MALLOC -DSUPPORT_REMOVE_MALLOC_LEGACY as above but will
 remove the three legacy functions from the binary to provide assurance
 they can not be used.

The system malloc is thread-safe the legacy magic malloc has a global
deferred free pointer and the mmap() allocate has a free-list that is
not thread-safe making use of free not thread-safe.
This could of course be improved with the use of
atomic_compare_and_exchange operations but for what gain ?

Then there is the additional function call overhead (of the indirection)
and a few tests/branches inserted into a commonly used code paths around
memory allocation, it hides the call site of the malloc/free usage from
the compiler which maybe have special optimization cases.

The existing malloc/free makes static code analysis around memory
allocation more problematic, also use of runtime analysers will operate
better with a fail-fast to bad memory usage.
2025-10-29 21:39:44 +00:00
..
2025-01-06 16:14:34 +00:00
2025-01-06 16:14:34 +00:00
2025-01-06 16:14:34 +00:00
2024-12-26 15:20:58 -05:00
2025-07-28 21:28:24 -04:00
2025-01-06 16:14:34 +00:00
2025-07-27 12:44:42 -04:00
2025-01-06 16:14:34 +00:00
2025-01-06 16:14:34 +00:00
2025-10-01 15:17:49 -04:00