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:
Borja Ferrer
2007-03-17 00:55:46 +00:00
parent c6166f4b44
commit 6e78ac6302
16 changed files with 135 additions and 81 deletions
-1
View File
@@ -264,7 +264,6 @@ void CExtensionManager::OnSourceModAllInitialized()
void CExtensionManager::OnSourceModShutdown()
{
g_RootMenu.RemoveRootConsoleCommand("exts", this);
g_PluginSys.RemovePluginsListener(this);
g_ShareSys.DestroyIdentType(g_ExtType);
}
+10 -5
View File
@@ -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;
+2 -1
View File
@@ -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);
+16 -16
View File
@@ -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;
+8 -1
View File
@@ -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)
+13 -13
View File
@@ -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.