[Scummvm-cvs-logs] SF.net SVN: scummvm:[54057] scummvm/trunk

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Thu Nov 4 01:49:13 CET 2010


Revision: 54057
          http://scummvm.svn.sourceforge.net/scummvm/?rev=54057&view=rev
Author:   fingolfin
Date:     2010-11-04 00:49:12 +0000 (Thu, 04 Nov 2010)

Log Message:
-----------
COMMON: Undo changes to common/ptr.h, remove Common::ScopedPtrC

The deletePointer() method approach cannot work, as it is called
by the destructor of the base class.
A possible correct solution would be to enhance ScopedPtr with a
"deleter" object like SharedPtr. But this seems overkill as long as we
need it in only one place.

Modified Paths:
--------------
    scummvm/trunk/backends/plugins/elf/elf-loader.cpp
    scummvm/trunk/common/ptr.h

Modified: scummvm/trunk/backends/plugins/elf/elf-loader.cpp
===================================================================
--- scummvm/trunk/backends/plugins/elf/elf-loader.cpp	2010-11-04 00:31:50 UTC (rev 54056)
+++ scummvm/trunk/backends/plugins/elf/elf-loader.cpp	2010-11-04 00:49:12 UTC (rev 54057)
@@ -320,24 +320,30 @@
 			return false;
 	}
 
-	Common::ScopedPtrC<Elf32_Shdr> shdr(loadSectionHeaders(&ehdr));
+	Elf32_Shdr *shdr = loadSectionHeaders(&ehdr);
 	if (!shdr)
 		return false;
 
 	_symtab_sect = loadSymbolTable(&ehdr, shdr);
-	if (_symtab_sect < 0)
+	if (_symtab_sect < 0) {
+		free(shdr);
 		return false;
+	}
 		
-	if (!loadStringTable(shdr))
+	if (!loadStringTable(shdr)) {
+		free(shdr);
 		return false;
+	}
 	
 	// Offset by our segment allocated address
 	// must use _segmentVMA here for multiple segments (MIPS)
 	_segmentOffset = ptrdiff_t(_segment) - _segmentVMA;
 	relocateSymbols(_segmentOffset);
 
-	if (!relocateRels(&ehdr, shdr))
+	if (!relocateRels(&ehdr, shdr)) {
+		free(shdr);
 		return false;
+	}
 
 	return true;
 }

Modified: scummvm/trunk/common/ptr.h
===================================================================
--- scummvm/trunk/common/ptr.h	2010-11-04 00:31:50 UTC (rev 54056)
+++ scummvm/trunk/common/ptr.h	2010-11-04 00:49:12 UTC (rev 54057)
@@ -242,17 +242,15 @@
 	 */
 	operator bool() const { return _pointer != 0; }
 
-	void deletePointer() { delete _pointer; }
-	
 	~ScopedPtr() {
-		deletePointer();		
+		delete _pointer;		
 	}
 
 	/**
 	 * Resets the pointer with the new value. Old object will be destroyed
 	 */
 	void reset(PointerType o = 0) {
-		deletePointer();
+		delete _pointer;
 		_pointer = o;
 	}
 
@@ -275,20 +273,10 @@
 		return r;
 	}
 
-protected:
+private:
 	PointerType _pointer;
 };
 
-template<typename T>
-class ScopedPtrC : public ScopedPtr<T> {
-public:
-	typedef T *PointerType;
-	
-	explicit ScopedPtrC(PointerType o = 0) : ScopedPtr<T>(o) {}
-	
-	void deletePointer() { free(ScopedPtr<T>::_pointer); }
-};
-
 } // End of namespace Common
 
 #endif


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