Made more de-allocation safety precautions

This commit is contained in:
David Anderson 2005-08-30 07:15:27 +00:00
parent 12f628e3d7
commit 63b2bbc67e

View File

@ -601,17 +601,21 @@ int unload_amxscript(AMX* amx, void** program)
if (!prg) if (!prg)
return AMX_ERR_NONE; return AMX_ERR_NONE;
#if defined JIT #if defined JIT
#if defined __linux__ && defined MEMORY_TEST #if defined __linux__
#undef free if ( (flags & AMX_FLAG_JITC) != AMX_FLAG_JITC )
if (flags & AMX_FLAG_DEBUG)
{ {
delete [] prg; delete [] prg;
} else { } else {
#ifdef free
#undef free
free(prg); free(prg);
}
#define free(ptr) m_deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr) #define free(ptr) m_deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
#else
free(prg);
#endif
}
#elif defined WIN32 #elif defined WIN32
if (flags & AMX_FLAG_DEBUG) if ( (flags & AMX_FLAG_JITC) != AMX_FLAG_JITC )
{ {
delete [] prg; delete [] prg;
} else if (!VirtualFree((LPVOID)prg, 0, MEM_RELEASE)) { } else if (!VirtualFree((LPVOID)prg, 0, MEM_RELEASE)) {
@ -621,7 +625,7 @@ int unload_amxscript(AMX* amx, void** program)
#endif //OS support #endif //OS support
#else #else
//delete normally //delete normally
delete[] prg; delete [] prg;
#endif #endif
*program = 0; *program = 0;
return AMX_ERR_NONE; return AMX_ERR_NONE;