diff options
-rw-r--r-- | backends/plugins/elf-loader.cpp | 4 | ||||
-rw-r--r-- | backends/plugins/elf-provider.cpp | 25 |
2 files changed, 16 insertions, 13 deletions
diff --git a/backends/plugins/elf-loader.cpp b/backends/plugins/elf-loader.cpp index 1b70ed5565..24532740b4 100644 --- a/backends/plugins/elf-loader.cpp +++ b/backends/plugins/elf-loader.cpp @@ -28,10 +28,10 @@ #include <string.h> #include <stdarg.h> #include <stdio.h> -#include <malloc.h> +#include <malloc.h> // for memalign() (Linux specific) #include <unistd.h> #include <sys/fcntl.h> -#include <sys/_default_fcntl.h> +#include <sys/_default_fcntl.h> // FIXME: Why do we need this DevKitPro specific header? #include "common/file.h" #include "common/fs.h" diff --git a/backends/plugins/elf-provider.cpp b/backends/plugins/elf-provider.cpp index cc592ca419..ae728495fa 100644 --- a/backends/plugins/elf-provider.cpp +++ b/backends/plugins/elf-provider.cpp @@ -33,7 +33,7 @@ class ELFPlugin : public DynamicPlugin { protected: - void *_dlHandle; + DLObject *_dlHandle; Common::String _filename; virtual VoidFunc findSymbol(const char *symbol) { @@ -43,7 +43,7 @@ protected: func = NULL; handleNull = true; } else { - func = ((DLObject *)_dlHandle)->symbol(symbol); + func = _dlHandle->symbol(symbol); } if (!func) { if (handleNull) { @@ -68,14 +68,15 @@ public: : _dlHandle(0), _filename(filename) {} ~ELFPlugin() { - if (_dlHandle) unloadPlugin(); + if (_dlHandle) + unloadPlugin(); } bool loadPlugin() { assert(!_dlHandle); DLObject *obj = new DLObject(NULL); if (obj->open(_filename.c_str())) { - _dlHandle = (void *)obj; + _dlHandle = obj; } else { delete obj; _dlHandle = NULL; @@ -88,9 +89,8 @@ public: bool ret = DynamicPlugin::loadPlugin(); - if (ret) { - if (_dlHandle != NULL) - ((DLObject *)_dlHandle)->discard_symtab(); + if (ret && _dlHandle) { + _dlHandle->discard_symtab(); } return ret; @@ -99,13 +99,15 @@ public: void unloadPlugin() { DynamicPlugin::unloadPlugin(); if (_dlHandle) { - DLObject *obj = (DLObject *)_dlHandle; - if (obj == NULL) { + if (_dlHandle == NULL) { + // FIXME: This check makes no sense, _dlHandle cannot be NULL at this point warning("Failed unloading plugin '%s' (Handle is NULL)", _filename.c_str()); - } else if (obj->close()) { - delete obj; + } else if (_dlHandle->close()) { + delete _dlHandle; } else { warning("Failed unloading plugin '%s'", _filename.c_str()); + // FIXME: We are leaking _dlHandle here! + // Any particular reasons why we would want to do that??? } _dlHandle = 0; } @@ -119,6 +121,7 @@ Plugin* ELFPluginProvider::createPlugin(const Common::FSNode &node) const { bool ELFPluginProvider::isPluginFilename(const Common::FSNode &node) const { // Check the plugin suffix + // FIXME: Do we need these printfs? Should get rid of them eventually. Common::String filename = node.getName(); printf("Testing name %s", filename.c_str()); if (!filename.hasSuffix(".PLG") && !filename.hasSuffix(".plg") && !filename.hasSuffix(".PLUGIN") && !filename.hasSuffix(".plugin")) { |