fixed several memory leaks
fixed plugin listeners being removed before a OnPluginUnloaded Call_AskPluginLoad removed some virtuality all cached ptrs using the Stack system are freed now --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40647
This commit is contained in:
parent
c6166f4b44
commit
6e78ac6302
@ -56,7 +56,6 @@ void ConCmdManager::OnSourceModShutdown()
|
||||
/* All commands should already be removed by the time we're done */
|
||||
SH_REMOVE_HOOK_MEMFUNC(IServerGameClients, SetCommandClient, serverClients, this, &ConCmdManager::SetCommandClient, false);
|
||||
g_RootMenu.RemoveRootConsoleCommand("cmds", this);
|
||||
g_PluginSys.RemovePluginsListener(this);
|
||||
}
|
||||
|
||||
void ConCmdManager::RemoveConCmds(List<CmdHook *> &cmdlist, IPluginContext *pContext)
|
||||
|
@ -46,6 +46,7 @@ CGameConfig::CGameConfig(const char *file)
|
||||
m_pProps = sm_trie_create();
|
||||
m_pKeys = sm_trie_create();
|
||||
m_pStrings = new BaseStringTable(512);
|
||||
m_RefCount = 0;
|
||||
}
|
||||
|
||||
CGameConfig::~CGameConfig()
|
||||
|
@ -27,6 +27,16 @@ void ITimer::Initialize(ITimedEvent *pCallbacks, float fInterval, float fToExec,
|
||||
m_KillMe = false;
|
||||
}
|
||||
|
||||
TimerSystem::~TimerSystem()
|
||||
{
|
||||
CStack<ITimer *>::iterator iter;
|
||||
for (iter=m_FreeTimers.begin(); iter!=m_FreeTimers.end(); iter++)
|
||||
{
|
||||
delete (*iter);
|
||||
}
|
||||
m_FreeTimers.popall();
|
||||
}
|
||||
|
||||
void TimerSystem::OnSourceModAllInitialized()
|
||||
{
|
||||
g_ShareSys.AddInterface(NULL, this);
|
||||
|
@ -44,6 +44,8 @@ class TimerSystem :
|
||||
public ITimerSystem,
|
||||
public SMGlobalClass
|
||||
{
|
||||
public:
|
||||
~TimerSystem();
|
||||
public: //SMGlobalClass
|
||||
void OnSourceModAllInitialized();
|
||||
public: //ITimerSystem
|
||||
|
@ -34,6 +34,13 @@ UserMessages::UserMessages() : m_InterceptBuffer(m_pBase, 2500)
|
||||
UserMessages::~UserMessages()
|
||||
{
|
||||
sm_trie_destroy(m_Names);
|
||||
|
||||
CStack<ListenerInfo *>::iterator iter;
|
||||
for (iter=m_FreeListeners.begin(); iter!=m_FreeListeners.end(); iter++)
|
||||
{
|
||||
delete (*iter);
|
||||
}
|
||||
m_FreeListeners.popall();
|
||||
}
|
||||
|
||||
void UserMessages::OnSourceModAllInitialized()
|
||||
|
@ -34,6 +34,8 @@ class TimerNatives :
|
||||
public IHandleTypeDispatch,
|
||||
public ITimedEvent
|
||||
{
|
||||
public:
|
||||
~TimerNatives();
|
||||
public: //ITimedEvent
|
||||
ResultType OnTimer(ITimer *pTimer, void *pData);
|
||||
void OnTimerEnd(ITimer *pTimer, void *pData);
|
||||
@ -49,6 +51,16 @@ private:
|
||||
CStack<TimerInfo *> m_FreeTimers;
|
||||
};
|
||||
|
||||
TimerNatives::~TimerNatives()
|
||||
{
|
||||
CStack<TimerInfo *>::iterator iter;
|
||||
for (iter=m_FreeTimers.begin(); iter!=m_FreeTimers.end(); iter++)
|
||||
{
|
||||
delete (*iter);
|
||||
}
|
||||
m_FreeTimers.popall();
|
||||
}
|
||||
|
||||
void TimerNatives::OnSourceModAllInitialized()
|
||||
{
|
||||
HandleAccess sec;
|
||||
|
@ -34,6 +34,8 @@ class UsrMessageNatives :
|
||||
public IHandleTypeDispatch,
|
||||
public IPluginsListener
|
||||
{
|
||||
public:
|
||||
~UsrMessageNatives();
|
||||
public: //SMGlobalClass, IHandleTypeDispatch, IPluginListener
|
||||
void OnSourceModAllInitialized();
|
||||
void OnSourceModShutdown();
|
||||
@ -47,6 +49,16 @@ private:
|
||||
CStack<MsgListenerWrapper *> m_FreeListeners;
|
||||
};
|
||||
|
||||
UsrMessageNatives::~UsrMessageNatives()
|
||||
{
|
||||
CStack<MsgListenerWrapper *>::iterator iter;
|
||||
for (iter=m_FreeListeners.begin(); iter!=m_FreeListeners.end(); iter++)
|
||||
{
|
||||
delete (*iter);
|
||||
}
|
||||
m_FreeListeners.popall();
|
||||
}
|
||||
|
||||
void UsrMessageNatives::OnSourceModAllInitialized()
|
||||
{
|
||||
HandleAccess sec;
|
||||
@ -70,7 +82,6 @@ void UsrMessageNatives::OnSourceModShutdown()
|
||||
g_HandleSys.RemoveType(g_WrBitBufType, g_pCoreIdent);
|
||||
g_HandleSys.RemoveType(g_RdBitBufType, g_pCoreIdent);
|
||||
|
||||
g_PluginSys.RemovePluginsListener(this);
|
||||
g_WrBitBufType = 0;
|
||||
g_RdBitBufType = 0;
|
||||
}
|
||||
|
@ -264,7 +264,6 @@ void CExtensionManager::OnSourceModAllInitialized()
|
||||
void CExtensionManager::OnSourceModShutdown()
|
||||
{
|
||||
g_RootMenu.RemoveRootConsoleCommand("exts", this);
|
||||
g_PluginSys.RemovePluginsListener(this);
|
||||
g_ShareSys.DestroyIdentType(g_ExtType);
|
||||
}
|
||||
|
||||
|
@ -32,17 +32,22 @@ CForwardManager g_Forwards;
|
||||
// :TODO: IMPORTANT!!! The result pointer arg in the execute function maybe invalid if the forward fails
|
||||
// so later evaluation of this result may cause problems on higher levels of abstraction. DOCUMENT OR FIX ALL FORWARDS!
|
||||
|
||||
CForwardManager::~CForwardManager()
|
||||
{
|
||||
CStack<CForward *>::iterator iter;
|
||||
for (iter=m_FreeForwards.begin(); iter!=m_FreeForwards.end(); iter++)
|
||||
{
|
||||
delete (*iter);
|
||||
}
|
||||
m_FreeForwards.popall();
|
||||
}
|
||||
|
||||
void CForwardManager::OnSourceModAllInitialized()
|
||||
{
|
||||
g_PluginSys.AddPluginsListener(this);
|
||||
g_ShareSys.AddInterface(NULL, this);
|
||||
}
|
||||
|
||||
void CForwardManager::OnSourceModShutdown()
|
||||
{
|
||||
g_PluginSys.RemovePluginsListener(this);
|
||||
}
|
||||
|
||||
IForward *CForwardManager::CreateForward(const char *name, ExecType et, unsigned int num_params, const ParamType *types, ...)
|
||||
{
|
||||
CForward *fwd;
|
||||
|
@ -105,6 +105,8 @@ class CForwardManager :
|
||||
public SMGlobalClass
|
||||
{
|
||||
friend class CForward;
|
||||
public:
|
||||
~CForwardManager();
|
||||
public: //IForwardManager
|
||||
IForward *CreateForward(const char *name,
|
||||
ExecType et,
|
||||
@ -124,7 +126,6 @@ public: //IPluginsListener
|
||||
void OnPluginPauseChange(IPlugin *plugin, bool paused);
|
||||
public: //SMGlobalClass
|
||||
void OnSourceModAllInitialized();
|
||||
void OnSourceModShutdown();
|
||||
protected:
|
||||
CForward *ForwardMake();
|
||||
void ForwardFree(CForward *fwd);
|
||||
|
@ -31,12 +31,12 @@ public:
|
||||
CDirectory(const char *path);
|
||||
~CDirectory();
|
||||
public:
|
||||
virtual bool MoreFiles();
|
||||
virtual void NextEntry();
|
||||
virtual const char *GetEntryName();
|
||||
virtual bool IsEntryDirectory();
|
||||
virtual bool IsEntryFile();
|
||||
virtual bool IsEntryValid();
|
||||
bool MoreFiles();
|
||||
void NextEntry();
|
||||
const char *GetEntryName();
|
||||
bool IsEntryDirectory();
|
||||
bool IsEntryFile();
|
||||
bool IsEntryValid();
|
||||
public:
|
||||
bool IsValid();
|
||||
private:
|
||||
@ -56,8 +56,8 @@ public:
|
||||
CLibrary(LibraryHandle me);
|
||||
~CLibrary();
|
||||
public:
|
||||
virtual void CloseLibrary();
|
||||
virtual void *GetSymbolAddress(const char *symname);
|
||||
void CloseLibrary();
|
||||
void *GetSymbolAddress(const char *symname);
|
||||
private:
|
||||
LibraryHandle m_lib;
|
||||
};
|
||||
@ -65,14 +65,14 @@ private:
|
||||
class LibrarySystem : public ILibrarySys
|
||||
{
|
||||
public:
|
||||
virtual ILibrary *OpenLibrary(const char *path, char *error, size_t err_max);
|
||||
virtual IDirectory *OpenDirectory(const char *path);
|
||||
virtual void CloseDirectory(IDirectory *dir);
|
||||
virtual bool PathExists(const char *path);
|
||||
virtual bool IsPathFile(const char *path);
|
||||
virtual bool IsPathDirectory(const char *path);
|
||||
virtual void GetPlatformError(char *error, size_t err_max);
|
||||
virtual size_t PathFormat(char *buffer, size_t len, const char *fmt, ...);
|
||||
ILibrary *OpenLibrary(const char *path, char *error, size_t err_max);
|
||||
IDirectory *OpenDirectory(const char *path);
|
||||
void CloseDirectory(IDirectory *dir);
|
||||
bool PathExists(const char *path);
|
||||
bool IsPathFile(const char *path);
|
||||
bool IsPathDirectory(const char *path);
|
||||
void GetPlatformError(char *error, size_t err_max);
|
||||
size_t PathFormat(char *buffer, size_t len, const char *fmt, ...);
|
||||
};
|
||||
|
||||
extern LibrarySystem g_LibSys;
|
||||
|
@ -78,7 +78,7 @@ CPlugin::~CPlugin()
|
||||
g_pSourcePawn->FreeFromMemory(m_plugin);
|
||||
m_plugin = NULL;
|
||||
}
|
||||
if (!m_pProps)
|
||||
if (m_pProps)
|
||||
{
|
||||
sm_trie_destroy(m_pProps);
|
||||
}
|
||||
@ -649,6 +649,13 @@ CPluginManager::~CPluginManager()
|
||||
*/
|
||||
sm_trie_destroy(m_LoadLookup);
|
||||
sm_trie_destroy(m_pNativeLookup);
|
||||
|
||||
CStack<CPluginManager::CPluginIterator *>::iterator iter;
|
||||
for (iter=m_iters.begin(); iter!=m_iters.end(); iter++)
|
||||
{
|
||||
delete (*iter);
|
||||
}
|
||||
m_iters.popall();
|
||||
}
|
||||
|
||||
void CPluginManager::LoadAll_FirstPass(const char *config, const char *basedir)
|
||||
|
@ -116,19 +116,19 @@ public:
|
||||
CPlugin(const char *file);
|
||||
~CPlugin();
|
||||
public:
|
||||
virtual PluginType GetType();
|
||||
virtual SourcePawn::IPluginContext *GetBaseContext();
|
||||
virtual sp_context_t *GetContext();
|
||||
virtual const sm_plugininfo_t *GetPublicInfo();
|
||||
virtual const char *GetFilename();
|
||||
virtual bool IsDebugging();
|
||||
virtual PluginStatus GetStatus();
|
||||
virtual bool SetPauseState(bool paused);
|
||||
virtual unsigned int GetSerial();
|
||||
virtual const sp_plugin_t *GetPluginStructure();
|
||||
virtual IdentityToken_t *GetIdentity();
|
||||
virtual bool SetProperty(const char *prop, void *ptr);
|
||||
virtual bool GetProperty(const char *prop, void **ptr, bool remove=false);
|
||||
PluginType GetType();
|
||||
SourcePawn::IPluginContext *GetBaseContext();
|
||||
sp_context_t *GetContext();
|
||||
const sm_plugininfo_t *GetPublicInfo();
|
||||
const char *GetFilename();
|
||||
bool IsDebugging();
|
||||
PluginStatus GetStatus();
|
||||
bool SetPauseState(bool paused);
|
||||
unsigned int GetSerial();
|
||||
const sp_plugin_t *GetPluginStructure();
|
||||
IdentityToken_t *GetIdentity();
|
||||
bool SetProperty(const char *prop, void *ptr);
|
||||
bool GetProperty(const char *prop, void **ptr, bool remove=false);
|
||||
public:
|
||||
/**
|
||||
* Creates a plugin object with default values.
|
||||
|
@ -36,43 +36,43 @@ namespace SourcePawn
|
||||
bool IsDebugging();
|
||||
int SetDebugBreak(SPVM_DEBUGBREAK newpfn, SPVM_DEBUGBREAK *oldpfn);
|
||||
IPluginDebugInfo *GetDebugInfo();
|
||||
virtual int HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr);
|
||||
virtual int HeapPop(cell_t local_addr);
|
||||
virtual int HeapRelease(cell_t local_addr);
|
||||
virtual int FindNativeByName(const char *name, uint32_t *index);
|
||||
virtual int GetNativeByIndex(uint32_t index, sp_native_t **native);
|
||||
virtual uint32_t GetNativesNum();
|
||||
virtual int FindPublicByName(const char *name, uint32_t *index);
|
||||
virtual int GetPublicByIndex(uint32_t index, sp_public_t **publicptr);
|
||||
virtual uint32_t GetPublicsNum();
|
||||
virtual int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar);
|
||||
virtual int FindPubvarByName(const char *name, uint32_t *index);
|
||||
virtual int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr);
|
||||
virtual uint32_t GetPubVarsNum();
|
||||
virtual int LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr);
|
||||
virtual int LocalToString(cell_t local_addr, char **addr);
|
||||
virtual int StringToLocal(cell_t local_addr, size_t chars, const char *source);
|
||||
virtual int StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *source, size_t *wrtnbytes);
|
||||
virtual int PushCell(cell_t value);
|
||||
virtual int PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells);
|
||||
virtual int PushString(cell_t *local_addr, char **phys_addr, const char *string);
|
||||
virtual int PushCellsFromArray(cell_t array[], unsigned int numcells);
|
||||
virtual int BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite);
|
||||
virtual int BindNative(const sp_nativeinfo_t *native);
|
||||
virtual int BindNativeToAny(SPVM_NATIVE_FUNC native);
|
||||
virtual int Execute(uint32_t code_addr, cell_t *result);
|
||||
virtual cell_t ThrowNativeErrorEx(int error, const char *msg, ...);
|
||||
virtual cell_t ThrowNativeError(const char *msg, ...);
|
||||
virtual IPluginFunction *GetFunctionByName(const char *public_name);
|
||||
virtual IPluginFunction *GetFunctionById(funcid_t func_id);
|
||||
int HeapAlloc(unsigned int cells, cell_t *local_addr, cell_t **phys_addr);
|
||||
int HeapPop(cell_t local_addr);
|
||||
int HeapRelease(cell_t local_addr);
|
||||
int FindNativeByName(const char *name, uint32_t *index);
|
||||
int GetNativeByIndex(uint32_t index, sp_native_t **native);
|
||||
uint32_t GetNativesNum();
|
||||
int FindPublicByName(const char *name, uint32_t *index);
|
||||
int GetPublicByIndex(uint32_t index, sp_public_t **publicptr);
|
||||
uint32_t GetPublicsNum();
|
||||
int GetPubvarByIndex(uint32_t index, sp_pubvar_t **pubvar);
|
||||
int FindPubvarByName(const char *name, uint32_t *index);
|
||||
int GetPubvarAddrs(uint32_t index, cell_t *local_addr, cell_t **phys_addr);
|
||||
uint32_t GetPubVarsNum();
|
||||
int LocalToPhysAddr(cell_t local_addr, cell_t **phys_addr);
|
||||
int LocalToString(cell_t local_addr, char **addr);
|
||||
int StringToLocal(cell_t local_addr, size_t chars, const char *source);
|
||||
int StringToLocalUTF8(cell_t local_addr, size_t maxbytes, const char *source, size_t *wrtnbytes);
|
||||
int PushCell(cell_t value);
|
||||
int PushCellArray(cell_t *local_addr, cell_t **phys_addr, cell_t array[], unsigned int numcells);
|
||||
int PushString(cell_t *local_addr, char **phys_addr, const char *string);
|
||||
int PushCellsFromArray(cell_t array[], unsigned int numcells);
|
||||
int BindNatives(const sp_nativeinfo_t *natives, unsigned int num, int overwrite);
|
||||
int BindNative(const sp_nativeinfo_t *native);
|
||||
int BindNativeToAny(SPVM_NATIVE_FUNC native);
|
||||
int Execute(uint32_t code_addr, cell_t *result);
|
||||
cell_t ThrowNativeErrorEx(int error, const char *msg, ...);
|
||||
cell_t ThrowNativeError(const char *msg, ...);
|
||||
IPluginFunction *GetFunctionByName(const char *public_name);
|
||||
IPluginFunction *GetFunctionById(funcid_t func_id);
|
||||
#if defined SOURCEMOD_BUILD
|
||||
virtual SourceMod::IdentityToken_t *GetIdentity();
|
||||
SourceMod::IdentityToken_t *GetIdentity();
|
||||
void SetIdentity(SourceMod::IdentityToken_t *token);
|
||||
#endif
|
||||
public: //IPluginDebugInfo
|
||||
virtual int LookupFile(ucell_t addr, const char **filename);
|
||||
virtual int LookupFunction(ucell_t addr, const char **name);
|
||||
virtual int LookupLine(ucell_t addr, uint32_t *line);
|
||||
int LookupFile(ucell_t addr, const char **filename);
|
||||
int LookupFunction(ucell_t addr, const char **name);
|
||||
int LookupLine(ucell_t addr, uint32_t *line);
|
||||
public:
|
||||
void SetContext(sp_context_t *_ctx);
|
||||
private:
|
||||
|
@ -32,13 +32,13 @@ class CContextTrace : public IContextTrace
|
||||
public:
|
||||
CContextTrace(TracedCall *pStart, int error, const char *msg, uint32_t native);
|
||||
public:
|
||||
virtual int GetErrorCode();
|
||||
virtual const char *GetErrorString();
|
||||
virtual bool DebugInfoAvailable();
|
||||
virtual const char *GetCustomErrorString();
|
||||
virtual bool GetTraceInfo(CallStackInfo *trace);
|
||||
virtual void ResetTrace();
|
||||
virtual const char *GetLastNative(uint32_t *index);
|
||||
int GetErrorCode();
|
||||
const char *GetErrorString();
|
||||
bool DebugInfoAvailable();
|
||||
const char *GetCustomErrorString();
|
||||
bool GetTraceInfo(CallStackInfo *trace);
|
||||
void ResetTrace();
|
||||
const char *GetLastNative(uint32_t *index);
|
||||
private:
|
||||
int m_Error;
|
||||
const char *m_pMsg;
|
||||
@ -47,7 +47,6 @@ private:
|
||||
uint32_t m_Native;
|
||||
};
|
||||
|
||||
|
||||
class SourcePawnEngine : public ISourcePawnEngine
|
||||
{
|
||||
public:
|
||||
|
@ -2259,6 +2259,7 @@ void JITX86::FreeContext(sp_context_t *ctx)
|
||||
engine->BaseFree(ctx->vm[JITVARS_REBASE]);
|
||||
free(((tracker_t *)(ctx->vm[JITVARS_TRACKER]))->pBase);
|
||||
delete (tracker_t *)ctx->vm[JITVARS_TRACKER];
|
||||
delete (functracker_t *)ctx->vm[JITVARS_FUNCINFO];
|
||||
delete ctx;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user