mirror of
https://github.com/scp-fs2open/fs2open.github.com.git
synced 2026-11-07 08:15:59 -10:00
This expands the existing system which only worked on Windows to all supported platforms. If the MSVC debug runtime is not present then its behavior is emulated by adding a header to each allocated memory block.
44 lines
823 B
C++
44 lines
823 B
C++
#ifndef NDEBUG
|
|
|
|
#include "debug.h"
|
|
|
|
#include "globalincs/pstypes.h"
|
|
|
|
// Generic non-quiet version that just call the specialized versions
|
|
|
|
void *_vm_malloc(size_t size, const char *filename, int line)
|
|
{
|
|
auto ptr = _vm_malloc(size, memory::quiet_alloc, filename, line);
|
|
|
|
if (ptr == nullptr)
|
|
{
|
|
memory::out_of_memory(filename, line);
|
|
}
|
|
|
|
return ptr;
|
|
}
|
|
|
|
void *_vm_realloc(void *ptr, size_t size, const char *filename, int line)
|
|
{
|
|
auto ret_ptr = _vm_realloc(ptr, size, memory::quiet_alloc, filename, line);
|
|
|
|
if (ret_ptr == nullptr)
|
|
{
|
|
memory::out_of_memory(filename, line);
|
|
}
|
|
|
|
return ret_ptr;
|
|
}
|
|
|
|
void* malloc_location(size_t size, const char* location, int line)
|
|
{
|
|
return _vm_malloc(size, location, line);
|
|
}
|
|
|
|
void free_location(void* ptr, const char* location, int line)
|
|
{
|
|
_vm_free(ptr, location, line);
|
|
}
|
|
|
|
#endif
|