idlib/Heap.h and idlib/Heap.cpp implement a replacement malloc/free.
From the header comments:
/* ===============================================================================
Memory Management
This is a replacement for the compiler heap code (i.e. "C" malloc() and free() calls). On average 2.5-3.0 times faster than MSVC malloc()/free(). Worst case performance is 1.65 times faster and best case > 70 times.
=============================================================================== */