SDK no longer manages memory by default

This commit is contained in:
David Anderson 2005-08-17 16:48:31 +00:00
parent 4e8eff3e04
commit 13c65f006b
3 changed files with 20 additions and 7 deletions

View File

@ -45,8 +45,6 @@
enginefuncs_t g_engfuncs; enginefuncs_t g_engfuncs;
globalvars_t *gpGlobals; globalvars_t *gpGlobals;
DLL_FUNCTIONS *g_pFunctionTable; DLL_FUNCTIONS *g_pFunctionTable;
DLL_FUNCTIONS *g_pFunctionTable_Post; DLL_FUNCTIONS *g_pFunctionTable_Post;
enginefuncs_t *g_pengfuncsTable; enginefuncs_t *g_pengfuncsTable;
@ -54,7 +52,6 @@ enginefuncs_t *g_pengfuncsTable_Post;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable; NEW_DLL_FUNCTIONS *g_pNewFunctionsTable;
NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post; NEW_DLL_FUNCTIONS *g_pNewFunctionsTable_Post;
// GetEntityAPI2 functions // GetEntityAPI2 functions
static DLL_FUNCTIONS g_EntityAPI_Table = static DLL_FUNCTIONS g_EntityAPI_Table =
{ {
@ -2481,9 +2478,11 @@ PFN_IS_PLAYER_CONNECTING g_fn_IsPlayerConnecting;
PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV; PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor; PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth; PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
#ifdef MEMORY_TEST
PFN_ALLOCATOR g_fn_Allocator; PFN_ALLOCATOR g_fn_Allocator;
PFN_REALLOCATOR g_fn_Reallocator; PFN_REALLOCATOR g_fn_Reallocator;
PFN_DEALLOCATOR g_fn_Deallocator; PFN_DEALLOCATOR g_fn_Deallocator;
#endif
PFN_AMX_EXEC g_fn_AmxExec; PFN_AMX_EXEC g_fn_AmxExec;
PFN_AMX_EXECV g_fn_AmxExecv; PFN_AMX_EXECV g_fn_AmxExecv;
PFN_AMX_ALLOT g_fn_AmxAllot; PFN_AMX_ALLOT g_fn_AmxAllot;
@ -2613,10 +2612,12 @@ C_DLLEXPORT int AMXX_Attach(PFN_REQ_FNPTR reqFnptrFunc)
REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT); REQFUNC("GetPlayerEdict", g_fn_GetPlayerEdict, PFN_GET_PLAYER_EDICT);
REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH); REQFUNC("amx_Push", g_fn_AmxPush, PFN_AMX_PUSH);
#ifdef MEMORY_TEST
// Memory // Memory
REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR); REQFUNC_OPT("Allocator", g_fn_Allocator, PFN_ALLOCATOR);
REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR); REQFUNC_OPT("Reallocator", g_fn_Reallocator, PFN_REALLOCATOR);
REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR); REQFUNC_OPT("Deallocator", g_fn_Deallocator, PFN_DEALLOCATOR);
#endif
REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL); REQFUNC("CellToReal", g_fn_CellToReal, PFN_CELL_TO_REAL);
REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL); REQFUNC("RealToCell", g_fn_RealToCell, PFN_REAL_TO_CELL);
@ -2735,6 +2736,8 @@ void ValidateMacros_DontCallThis_Smiley()
} }
#endif #endif
#ifdef MEMORY_TEST
/************* MEMORY *************/ /************* MEMORY *************/
// undef all defined macros // undef all defined macros
#undef new #undef new
@ -2906,6 +2909,8 @@ void operator delete[](void *reportedAddress)
Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress); Mem_Deallocator(g_Mem_CurrentFilename, g_Mem_CurrentLine, g_Mem_CurrentFunc, m_alloc_delete_array, reportedAddress);
} }
#endif //MEMORY_TEST
/************* stuff from dlls/util.cpp *************/ /************* stuff from dlls/util.cpp *************/
// must come here because cbase.h declares it's own operator new // must come here because cbase.h declares it's own operator new

View File

@ -46,8 +46,6 @@ struct amxx_module_info_s
const char *logtag; // added in version 2 const char *logtag; // added in version 2
}; };
// return values from functions called by amxx // return values from functions called by amxx
#define AMXX_OK 0 /* no error */ #define AMXX_OK 0 /* no error */
#define AMXX_IFVERS 1 /* interface version */ #define AMXX_IFVERS 1 /* interface version */
@ -1981,12 +1979,14 @@ typedef edict_t * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/); typedef void * (*PFN_GET_PLAYER_EDICT) (int /*id*/);
#endif #endif
#ifdef MEMORY_TEST
typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/, typedef void * (*PFN_ALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const size_t /*size*/); const unsigned int /*type*/, const size_t /*size*/);
typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/, typedef void * (*PFN_REALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ ); const unsigned int /*type*/, const size_t /*size*/, void* /*addr*/ );
typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/, typedef void (*PFN_DEALLOCATOR) (const char* /*filename*/, const unsigned int /*line*/, const char* /*func*/,
const unsigned int /*type*/, const void* /*addr*/ ); const unsigned int /*type*/, const void* /*addr*/ );
#endif
typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/); typedef int (*PFN_AMX_EXEC) (AMX* /*amx*/, cell* /*return val*/, int /*index*/);
typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/); typedef int (*PFN_AMX_EXECV) (AMX* /*amx*/, cell* /*return val*/, int /*index*/, int /*numparams*/, cell[] /*params*/);
typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/); typedef int (*PFN_AMX_ALLOT) (AMX* /*amx*/, int /*length*/, cell* /*amx_addr*/, cell** /*phys_addr*/);
@ -2048,7 +2048,6 @@ extern PFN_IS_PLAYER_HLTV g_fn_IsPlayerHLTV;
extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor; extern PFN_GET_PLAYER_ARMOR g_fn_GetPlayerArmor;
extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth; extern PFN_GET_PLAYER_HEALTH g_fn_GetPlayerHealth;
extern PFN_AMX_EXEC g_fn_AmxExec; extern PFN_AMX_EXEC g_fn_AmxExec;
extern PFN_AMX_EXECV g_fn_AmxExecv;
extern PFN_AMX_ALLOT g_fn_AmxAllot; extern PFN_AMX_ALLOT g_fn_AmxAllot;
extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic; extern PFN_AMX_FINDPUBLIC g_fn_AmxFindPublic;
extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript; extern PFN_LOAD_AMXSCRIPT g_fn_LoadAmxScript;
@ -2193,6 +2192,7 @@ void MF_LogError(AMX *amx, int err, const char *fmt, ...);
#define MF_RequestFunction g_fn_RequestFunction; #define MF_RequestFunction g_fn_RequestFunction;
#define MF_AmxPush g_fn_AmxPush #define MF_AmxPush g_fn_AmxPush
#ifdef MEMORY_TEST
/*** Memory ***/ /*** Memory ***/
void *operator new(size_t reportedSize); void *operator new(size_t reportedSize);
void *operator new[](size_t reportedSize); void *operator new[](size_t reportedSize);
@ -2236,4 +2236,6 @@ void Mem_Deallocator(const char *sourceFile, const unsigned int sourceLine, cons
#define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr) #define realloc(ptr,sz) Mem_Reallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_realloc,sz,ptr)
#define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr) #define free(ptr) Mem_Deallocator(__FILE__,__LINE__,__FUNCTION__,m_alloc_free,ptr)
#endif //MEMORY_TEST
#endif // #ifndef __AMXXMODULE_H__ #endif // #ifndef __AMXXMODULE_H__

View File

@ -21,6 +21,12 @@
// metamod plugin? // metamod plugin?
// #define USE_METAMOD // #define USE_METAMOD
// use memory manager/tester?
// note that if you use this, you cannot construct/allocate
// anything before the module attached (OnAmxxAttach).
// be careful of default constructors using new/malloc!
// #define MEMORY_TEST
// - AMXX Init functions // - AMXX Init functions
// Also consider using FN_META_* // Also consider using FN_META_*
// AMXX query // AMXX query