From 77fffb46b2e7a22b47a3ae4e4633a69da10e16c5 Mon Sep 17 00:00:00 2001 From: Pavol Marko Date: Sat, 11 Sep 2004 21:52:18 +0000 Subject: [PATCH] Added allocator / reallocator / reallocator funcs in not-memtest builds so modules can use them --- amxmodx/modules.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/amxmodx/modules.cpp b/amxmodx/modules.cpp index 54810cb9..5ff4253f 100755 --- a/amxmodx/modules.cpp +++ b/amxmodx/modules.cpp @@ -959,6 +959,23 @@ const char *MNF_Format(const char *fmt, ...) return retVal; } +#ifndef MEMORY_TEST +void *MNF_Allocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, const unsigned int allocationType, const size_t reportedSize) +{ + return malloc(reportedSize); +} + +void *MNF_Reallocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, const unsigned int reallocationType, const size_t reportedSize, void *reportedAddress) +{ + return realloc(reportedAddress, reportedSize); +} + +void MNF_Deallocator(const char *sourceFile, const unsigned int sourceLine, const char *sourceFunc, const unsigned int deallocationType, void *reportedAddress) +{ + free(reportedAddress); +} +#endif + // Fnptr Request function for the new interface const char *g_LastRequestedFunc = NULL; #define REGISTER_FUNC(name, func) { name, (void*)func }, @@ -1042,6 +1059,10 @@ void *Module_ReqFnptr(const char *funcName) REGISTER_FUNC("Allocator", m_allocator) REGISTER_FUNC("Deallocator", m_deallocator) REGISTER_FUNC("Reallocator", m_reallocator) +#else + REGISTER_FUNC("Allocator", MNF_Allocator) + REGISTER_FUNC("Deallocator", MNF_Deallocator) + REGISTER_FUNC("Reallocator", MNF_Reallocator) #endif // MEMORY_TEST REGISTER_FUNC("Haha_HiddenStuff", MNF_HiddenStuff)