diff options
author | Max Horn | 2010-08-03 12:45:12 +0000 |
---|---|---|
committer | Max Horn | 2010-08-03 12:45:12 +0000 |
commit | 9f5bcadaea8bb51efb21d23b24a3ff4fafd9bb05 (patch) | |
tree | 08c0d939afffc0b2fd6111045056a9eedafcd498 | |
parent | 9be8f0a544510ae0843fce47c613af0de7f1df17 (diff) | |
download | scummvm-rg350-9f5bcadaea8bb51efb21d23b24a3ff4fafd9bb05.tar.gz scummvm-rg350-9f5bcadaea8bb51efb21d23b24a3ff4fafd9bb05.tar.bz2 scummvm-rg350-9f5bcadaea8bb51efb21d23b24a3ff4fafd9bb05.zip |
Simplify code a bit, add several FIXMEs
svn-id: r51688
-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")) { |