diff options
| author | 2007-04-23 09:39:23 +0000 | |
|---|---|---|
| committer | 2007-04-23 09:39:23 +0000 | |
| commit | adf2d3863b679fbf5f7b579ceacddb752c4a9103 (patch) | |
| tree | c3457673a2267986d4267c066e1e140d652ff9bc /src/modules/system/plugin.cpp | |
| parent | removed _free function of plugin (diff) | |
| download | KVIrc-adf2d3863b679fbf5f7b579ceacddb752c4a9103.tar.gz KVIrc-adf2d3863b679fbf5f7b579ceacddb752c4a9103.tar.bz2 KVIrc-adf2d3863b679fbf5f7b579ceacddb752c4a9103.zip | |
added _free function again due problems while freeing memory
git-svn-id: https://svn.kvirc.de/svn/trunk/kvirc@529 17fca916-40b9-46aa-a4ea-0a15b648b75c
Diffstat (limited to 'src/modules/system/plugin.cpp')
| -rw-r--r-- | src/modules/system/plugin.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/modules/system/plugin.cpp b/src/modules/system/plugin.cpp index ba18ade47..9d91c12b4 100644 --- a/src/modules/system/plugin.cpp +++ b/src/modules/system/plugin.cpp @@ -47,6 +47,16 @@ @body: TODO [b]Exported functions by dll[/b][br] + [br]_free function (needed)[br] + [example] + int _free(void * p)[br] + {[br] + // Always free the memory here![br] + free(p);[br] + return 0;[br] + }[br] + [/example] + [br]_load function (optional)[br] [example] int _load()[br] @@ -105,6 +115,20 @@ KviPlugin* KviPlugin::load(const QString& szFileName) return pPlugin; } +bool KviPlugin::pfree(char * pBuffer) +{ + plugin_free function_free; + + function_free = (plugin_free)kvi_library_symbol(m_Plugin,"_free"); + if (function_free) + { + //TODO: THREAD + if(pBuffer) function_free(pBuffer); + return true; + } + return false; +} + bool KviPlugin::unload(bool forced) { plugin_unload function_unload; @@ -264,7 +288,16 @@ bool KviPluginManager::pluginCall(KviKvsModuleFunctionCall *c) //Clean up if(pArgvBuffer) free(pArgvBuffer); if(ppArgv) free(ppArgv); - if(returnBuffer) free(returnBuffer); + if(returnBuffer) + { + if (!plugin->pfree(returnBuffer)) + { + c->warning(__tr2qs("The plugin has no function to free memory. Can result in Memory Leaks!")); + } + } + + + return true; } |
