[Scummvm-cvs-logs] SF.net SVN: scummvm:[51688] scummvm/branches/gsoc2010-plugins/backends/ plugins

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Aug 3 14:45:12 CEST 2010


Revision: 51688
          http://scummvm.svn.sourceforge.net/scummvm/?rev=51688&view=rev
Author:   fingolfin
Date:     2010-08-03 12:45:12 +0000 (Tue, 03 Aug 2010)

Log Message:
-----------
Simplify code a bit, add several FIXMEs

Modified Paths:
--------------
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
    scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp	2010-08-03 12:41:36 UTC (rev 51687)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-loader.cpp	2010-08-03 12:45:12 UTC (rev 51688)
@@ -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"

Modified: scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp
===================================================================
--- scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp	2010-08-03 12:41:36 UTC (rev 51687)
+++ scummvm/branches/gsoc2010-plugins/backends/plugins/elf-provider.cpp	2010-08-03 12:45:12 UTC (rev 51688)
@@ -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 @@
 			func = NULL;
 			handleNull = true;
 		} else {
-			func = ((DLObject *)_dlHandle)->symbol(symbol);
+			func = _dlHandle->symbol(symbol);
 		}
 		if (!func) {
 			if (handleNull) {
@@ -68,14 +68,15 @@
 		: _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 @@
 
 		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 @@
 	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 @@
 
 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")) {


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list