[Scummvm-cvs-logs] SF.net SVN: scummvm:[41079] scummvm/trunk/engines/gob

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Sun May 31 19:00:39 CEST 2009


Revision: 41079
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41079&view=rev
Author:   fingolfin
Date:     2009-05-31 17:00:38 +0000 (Sun, 31 May 2009)

Log Message:
-----------
GOB: Got rid of last traces of strdupcpy and strdupcat

Modified Paths:
--------------
    scummvm/trunk/engines/gob/helper.h
    scummvm/trunk/engines/gob/save/saveconverter.cpp
    scummvm/trunk/engines/gob/save/saveconverter.h
    scummvm/trunk/engines/gob/save/saveconverter_v2.cpp
    scummvm/trunk/engines/gob/save/saveconverter_v3.cpp
    scummvm/trunk/engines/gob/save/saveconverter_v4.cpp
    scummvm/trunk/engines/gob/save/saveconverter_v6.cpp
    scummvm/trunk/engines/gob/save/savehandler.cpp
    scummvm/trunk/engines/gob/save/savehandler.h
    scummvm/trunk/engines/gob/save/saveload_v2.cpp
    scummvm/trunk/engines/gob/save/saveload_v3.cpp
    scummvm/trunk/engines/gob/save/saveload_v4.cpp
    scummvm/trunk/engines/gob/save/saveload_v6.cpp

Modified: scummvm/trunk/engines/gob/helper.h
===================================================================
--- scummvm/trunk/engines/gob/helper.h	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/helper.h	2009-05-31 17:00:38 UTC (rev 41079)
@@ -35,36 +35,6 @@
 	return dest;
 }
 
-/** A strdup that new[]s the buffer. */
-inline char *strdupcpy(const char *str) {
-	if (!str)
-		return 0;
-
-	size_t len = strlen(str) + 1;
-
-	char *nstr = new char[len];
-
-	memcpy(nstr, str, len);
-
-	return nstr;
-}
-
-/** A strcat that new[]s the buffer. */
-inline char *strdupcat(const char *str1, const char *str2) {
-	if (!str1 || !str2)
-		return 0;
-
-	size_t len1 = strlen(str1);
-	size_t len2 = strlen(str2);
-
-	char *nstr = new char[len1 + len2 + 1];
-
-	memcpy(nstr, str1, len1);
-	memcpy(nstr + len1, str2, len2 + 1);
-
-	return nstr;
-}
-
 /** A "smart" reference counting templated class. */
 template<typename T>
 class ReferenceCounter {

Modified: scummvm/trunk/engines/gob/save/saveconverter.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveconverter.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveconverter.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -72,7 +72,7 @@
 	        "save is broken and can't be used anymore. Sorry for the inconvenience");
 }
 
-char *SaveConverter::getDescription(const char *fileName) {
+char *SaveConverter::getDescription(const Common::String &fileName) {
 	setFileName(fileName);
 	return getDescription();
 }
@@ -357,7 +357,7 @@
 
 
 SaveConverter_Notes::SaveConverter_Notes(GobEngine *vm, uint32 notesSize,
-		const char *fileName) : SaveConverter(vm, fileName) {
+		const Common::String &fileName) : SaveConverter(vm, fileName) {
 
 	_size = notesSize;
 }

Modified: scummvm/trunk/engines/gob/save/saveconverter.h
===================================================================
--- scummvm/trunk/engines/gob/save/saveconverter.h	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveconverter.h	2009-05-31 17:00:38 UTC (rev 41079)
@@ -56,7 +56,7 @@
 	virtual bool load() = 0;
 
 	/** Set the name and return the description. */
-	char *getDescription(const char *fileName);
+	char *getDescription(const Common::String &fileName);
 	/** Get the current fileName's description. */
 	char *getDescription() const;
 
@@ -108,7 +108,7 @@
 /** A wrapper for old notes saves. */
 class SaveConverter_Notes : public SaveConverter {
 public:
-	SaveConverter_Notes(GobEngine *vm, uint32 notesSize, const char *fileName = 0);
+	SaveConverter_Notes(GobEngine *vm, uint32 notesSize, const Common::String &fileName = "");
 	~SaveConverter_Notes();
 
 	int isOldSave(Common::InSaveFile **save = 0) const;
@@ -125,7 +125,7 @@
 /** A wrapper for old v2-style saves (Gobliins 2, Ween: The Prophecy and Bargon Attack). */
 class SaveConverter_v2 : public SaveConverter {
 public:
-	SaveConverter_v2(GobEngine *vm, const char *fileName = 0);
+	SaveConverter_v2(GobEngine *vm, const Common::String &fileName = "");
 	~SaveConverter_v2();
 
 	int isOldSave(Common::InSaveFile **save = 0) const;
@@ -144,7 +144,7 @@
 /** A wrapper for old v3-style saves (Goblins 3 and Lost in Time). */
 class SaveConverter_v3 : public SaveConverter {
 public:
-	SaveConverter_v3(GobEngine *vm, const char *fileName = 0);
+	SaveConverter_v3(GobEngine *vm, const Common::String &fileName = "");
 	~SaveConverter_v3();
 
 	int isOldSave(Common::InSaveFile **save = 0) const;
@@ -166,7 +166,7 @@
 /** A wrapper for old v4-style saves (Woodruff). */
 class SaveConverter_v4 : public SaveConverter {
 public:
-	SaveConverter_v4(GobEngine *vm, const char *fileName = 0);
+	SaveConverter_v4(GobEngine *vm, const Common::String &fileName = "");
 	~SaveConverter_v4();
 
 	int isOldSave(Common::InSaveFile **save = 0) const;
@@ -185,7 +185,7 @@
 /** A wrapper for old v6-style saves (Urban Runner). */
 class SaveConverter_v6 : public SaveConverter {
 public:
-	SaveConverter_v6(GobEngine *vm, const char *fileName = 0);
+	SaveConverter_v6(GobEngine *vm, const Common::String &fileName = "");
 	~SaveConverter_v6();
 
 	int isOldSave(Common::InSaveFile **save = 0) const;

Modified: scummvm/trunk/engines/gob/save/saveconverter_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveconverter_v2.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveconverter_v2.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -33,7 +33,7 @@
 
 namespace Gob {
 
-SaveConverter_v2::SaveConverter_v2(GobEngine *vm, const char *fileName) :
+SaveConverter_v2::SaveConverter_v2(GobEngine *vm, const Common::String &fileName) :
 	SaveConverter(vm, fileName) {
 }
 

Modified: scummvm/trunk/engines/gob/save/saveconverter_v3.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveconverter_v3.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveconverter_v3.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -33,7 +33,7 @@
 
 namespace Gob {
 
-SaveConverter_v3::SaveConverter_v3(GobEngine *vm, const char *fileName) :
+SaveConverter_v3::SaveConverter_v3(GobEngine *vm, const Common::String &fileName) :
 	SaveConverter(vm, fileName) {
 }
 

Modified: scummvm/trunk/engines/gob/save/saveconverter_v4.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveconverter_v4.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveconverter_v4.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -33,7 +33,7 @@
 
 namespace Gob {
 
-SaveConverter_v4::SaveConverter_v4(GobEngine *vm, const char *fileName) :
+SaveConverter_v4::SaveConverter_v4(GobEngine *vm, const Common::String &fileName) :
 	SaveConverter(vm, fileName) {
 }
 

Modified: scummvm/trunk/engines/gob/save/saveconverter_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveconverter_v6.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveconverter_v6.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -33,7 +33,7 @@
 
 namespace Gob {
 
-SaveConverter_v6::SaveConverter_v6(GobEngine *vm, const char *fileName) :
+SaveConverter_v6::SaveConverter_v6(GobEngine *vm, const Common::String &fileName) :
 	SaveConverter(vm, fileName) {
 }
 

Modified: scummvm/trunk/engines/gob/save/savehandler.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/savehandler.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/savehandler.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -37,32 +37,26 @@
 
 namespace Gob {
 
-SlotFile::SlotFile(GobEngine *vm, uint32 slotCount, const char *base) : _vm(vm) {
-	_base = strdupcpy(base);
+SlotFile::SlotFile(GobEngine *vm, uint32 slotCount, const Common::String &base) : _vm(vm) {
+	_base = base;
 	_slotCount = slotCount;
 }
 
 SlotFile::~SlotFile() {
-	delete[] _base;
 }
 
-const char *SlotFile::getBase() const {
-	return _base;
-}
-
 uint32 SlotFileIndexed::getSlotMax() const {
 	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
 	Common::InSaveFile *in;
 
 	// Find the last filled save slot and base the save file size calculate on that
 	for (int i = (_slotCount - 1); i >= 0; i--) {
-		char *slotFile = build(i);
+		Common::String slotFile = build(i);
 
-		if (!slotFile)
+		if (slotFile.empty())
 			continue;
 
 		in = saveMan->openForLoading(slotFile);
-		delete[] slotFile;
 
 		if (in) {
 			delete in;
@@ -89,9 +83,9 @@
 
 	// Iterate over all files
 	for (uint32 i = 0; i < _slotCount; i++, buffer += descLength) {
-		char *slotFile = build(i);
+		Common::String slotFile = build(i);
 
-		if (slotFile) {
+		if (!slotFile.empty()) {
 			char *desc = 0;
 
 			if (converter && (desc = converter->getDescription(slotFile)))
@@ -109,8 +103,6 @@
 		} else
 			// No valid slot, fill with 0
 			memset(buffer, 0, descLength);
-
-		delete[] slotFile;
 	}
 }
 
@@ -121,85 +113,51 @@
 	return result;
 }
 
-bool SlotFileStatic::exists() const {
-	Common::InSaveFile *in = openRead();
-	bool result = (in != 0);
-	delete in;
-	return result;
-}
-
 Common::InSaveFile *SlotFileIndexed::openRead(int slot) const {
-	char *name = build(slot);
-	if (!name)
+	Common::String name = build(slot);
+	if (name.empty())
 		return 0;
 	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
 	Common::InSaveFile *result = saveMan->openForLoading(name);
-	delete[] name;
 	return result;
 }
 
-Common::InSaveFile *SlotFileStatic::openRead() const {
-	char *name = build();
-	if (!name)
-		return 0;
-	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
-	Common::InSaveFile *result = saveMan->openForLoading(name);
-	delete[] name;
-	return result;
-}
-
 Common::OutSaveFile *SlotFileIndexed::openWrite(int slot) const {
-	char *name = build(slot);
-	if (!name)
+	Common::String name = build(slot);
+	if (name.empty())
 		return 0;
 	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
 	Common::OutSaveFile *result = saveMan->openForSaving(name);
-	delete[] name;
 	return result;
 }
 
-Common::OutSaveFile *SlotFileStatic::openWrite() const {
-	char *name = build();
-	if (!name)
-		return 0;
-	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
-	Common::OutSaveFile *result = saveMan->openForSaving(name);
-	delete[] name;
-	return result;
-}
 
-
 SlotFileIndexed::SlotFileIndexed(GobEngine *vm, uint32 slotCount,
-		const char *base, const char *extStub) : SlotFile(vm, slotCount, base) {
+		const Common::String &base, const Common::String &extStub) : SlotFile(vm, slotCount, base) {
 
-	_ext = strdupcpy(extStub);
+	_ext = extStub;
 }
 
 SlotFileIndexed::~SlotFileIndexed() {
-	delete[] _ext;
 }
 
-char *SlotFileIndexed::build(int slot) const {
+Common::String SlotFileIndexed::build(int slot) const {
 	if ((slot < 0) || (((uint32) slot) >= _slotCount))
-		return 0;
+		return Common::String();
 
-	size_t len = strlen(_base) + strlen(_ext) + 4;
+	char buf[4];
+	snprintf(buf, sizeof(buf), "%02d", slot);
 
-	char *slotFile = new char[len];
-
-	snprintf(slotFile, len, "%s.%s%02d", _base, _ext, slot);
-
-	return slotFile;
+	return _base + "." + _ext + buf;
 }
 
-SlotFileStatic::SlotFileStatic(GobEngine *vm, const char *base,
-		const char *ext) : SlotFile(vm, 1, base) {
+SlotFileStatic::SlotFileStatic(GobEngine *vm, const Common::String &base,
+		const Common::String &ext) : SlotFile(vm, 1, base) {
 
-	_ext = strdupcat(".", ext);
+	_ext = "." + ext;
 }
 
 SlotFileStatic::~SlotFileStatic() {
-	delete[] _ext;
 }
 
 int SlotFileStatic::getSlot(int32 offset) const {
@@ -210,11 +168,36 @@
 	return -1;
 }
 
-char *SlotFileStatic::build() const {
-	return strdupcat(_base, _ext);
+Common::String SlotFileStatic::build() const {
+	return _base + _ext;
 }
 
+bool SlotFileStatic::exists() const {
+	Common::InSaveFile *in = openRead();
+	bool result = (in != 0);
+	delete in;
+	return result;
+}
 
+Common::InSaveFile *SlotFileStatic::openRead() const {
+	Common::String name = build();
+	if (name.empty())
+		return 0;
+	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
+	Common::InSaveFile *result = saveMan->openForLoading(name);
+	return result;
+}
+
+Common::OutSaveFile *SlotFileStatic::openWrite() const {
+	Common::String name = build();
+	if (name.empty())
+		return 0;
+	Common::SaveFileManager *saveMan = g_system->getSavefileManager();
+	Common::OutSaveFile *result = saveMan->openForSaving(name);
+	return result;
+}
+
+
 SaveHandler::SaveHandler(GobEngine *vm) : _vm(vm) {
 }
 
@@ -357,14 +340,14 @@
 }
 
 
-NotesHandler::File::File(GobEngine *vm, const char *base) :
+NotesHandler::File::File(GobEngine *vm, const Common::String &base) :
 	SlotFileStatic(vm, base, "blo") {
 }
 
 NotesHandler::File::~File() {
 }
 
-NotesHandler::NotesHandler(uint32 notesSize, GobEngine *vm, const char *target) :
+NotesHandler::NotesHandler(uint32 notesSize, GobEngine *vm, const Common::String &target) :
 	SaveHandler(vm) {
 
 	_notesSize = notesSize;
@@ -380,9 +363,9 @@
 }
 
 int32 NotesHandler::getSize() {
-	char *fileName = _file->build();
+	Common::String fileName = _file->build();
 
-	if (!fileName)
+	if (fileName.empty())
 		return -1;
 
 	Common::InSaveFile *saveFile;
@@ -400,8 +383,6 @@
 	SaveReader reader(1, 0, fileName);
 	SaveHeader header;
 
-	delete[] fileName;
-
 	if (!reader.load())
 		return -1;
 
@@ -416,9 +397,9 @@
 	if ((dataVar < 0) || (size < 0) || (offset < 0))
 		return false;
 
-	char *fileName = _file->build();
+	Common::String fileName = _file->build();
 
-	if (!fileName)
+	if (fileName.empty())
 		return false;
 
 	SaveReader *reader;
@@ -437,8 +418,6 @@
 
 	SavePartVars vars(_vm, _notesSize);
 
-	delete[] fileName;
-
 	if (!reader->load()) {
 		delete reader;
 		return false;
@@ -462,16 +441,14 @@
 	if ((dataVar < 0) || (size < 0) || (offset < 0))
 		return false;
 
-	char *fileName = _file->build();
+	Common::String fileName = _file->build();
 
-	if (!fileName)
+	if (fileName.empty())
 		return false;
 
 	SaveWriter writer(1, 0, fileName);
 	SavePartVars vars(_vm, _notesSize);
 
-	delete[] fileName;
-
 	if (!vars.readFrom(dataVar, offset, size))
 		return false;
 

Modified: scummvm/trunk/engines/gob/save/savehandler.h
===================================================================
--- scummvm/trunk/engines/gob/save/savehandler.h	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/savehandler.h	2009-05-31 17:00:38 UTC (rev 41079)
@@ -45,12 +45,9 @@
 	 *  @param slotCount Number of slots.
 	 *  @param base The file's base string.
 	 */
-	SlotFile(GobEngine *vm, uint32 slotCount, const char *base);
+	SlotFile(GobEngine *vm, uint32 slotCount, const Common::String &base);
 	virtual ~SlotFile();
 
-	/** Returns the base string. */
-	virtual const char *getBase() const;
-
 	/** Calculates which slot to use. */
 	virtual int getSlot(int32 offset) const = 0;
 	/** Calculates the slot remainder, for error checking. */
@@ -58,7 +55,7 @@
 
 protected:
 	GobEngine *_vm;
-	char *_base;
+	Common::String _base;
 
 	uint32 _slotCount;
 };
@@ -66,12 +63,12 @@
 /** An indexed slot file ("foobar.s00", "foobar.s01", ...). */
 class SlotFileIndexed : public SlotFile {
 public:
-	SlotFileIndexed(GobEngine *vm, uint32 slotCount, const char *base,
-			const char *extStub);
+	SlotFileIndexed(GobEngine *vm, uint32 slotCount, const Common::String &base,
+			const Common::String &extStub);
 	~SlotFileIndexed();
 
 	/** Build the save file name. */
-	char *build(int slot) const;
+	Common::String build(int slot) const;
 
 	/** Returns the highest filled slot number. */
 	virtual uint32 getSlotMax() const;
@@ -88,27 +85,27 @@
 	virtual Common::OutSaveFile *openWrite(int slot) const;
 
 protected:
-	char *_ext;
+	Common::String _ext;
 };
 
 /** A static slot file ("foo.bar"). */
 class SlotFileStatic : public SlotFile {
 public:
-	SlotFileStatic(GobEngine *vm, const char *base, const char *ext);
+	SlotFileStatic(GobEngine *vm, const Common::String &base, const Common::String &ext);
 	~SlotFileStatic();
 
 	int getSlot(int32 offset) const;
 	int getSlotRemainder(int32 offset) const;
 
 	/** Build the save file name. */
-	char *build() const;
+	Common::String build() const;
 
 	virtual bool exists() const;
 	virtual Common::InSaveFile *openRead() const;
 	virtual Common::OutSaveFile *openWrite() const;
 
 protected:
-	char *_ext;
+	Common::String _ext;
 };
 
 /** A handler for a specific save file. */
@@ -158,7 +155,7 @@
 /** A handler for notes. */
 class NotesHandler : public SaveHandler {
 public:
-	NotesHandler(uint32 notesSize, GobEngine *vm, const char *target);
+	NotesHandler(uint32 notesSize, GobEngine *vm, const Common::String &target);
 	~NotesHandler();
 
 	int32 getSize();
@@ -168,7 +165,7 @@
 private:
 	class File : public SlotFileStatic {
 	public:
-		File(GobEngine *vm, const char *base);
+		File(GobEngine *vm, const Common::String &base);
 		~File();
 	};
 

Modified: scummvm/trunk/engines/gob/save/saveload_v2.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveload_v2.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveload_v2.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -124,7 +124,7 @@
 			return false;
 		}
 
-		char *slotFile = _slotFile->build(slot);
+		Common::String slotFile = _slotFile->build(slot);
 
 		SaveReader *reader = 0;
 		SaveConverter_v2 converter(_vm, slotFile);
@@ -149,8 +149,6 @@
 			return false;
 		}
 
-		delete[] slotFile;
-
 		if (!reader->readPart(0, &info)) {
 			delete reader;
 			return false;
@@ -220,15 +218,13 @@
 
 		_hasIndex = false;
 
-		char *slotFile = _slotFile->build(slot);
+		Common::String slotFile = _slotFile->build(slot);
 
 		SaveWriter writer(2, slot, slotFile);
 		SavePartInfo info(kSlotNameLength, (uint32) _vm->getGameType(), 0,
 				_vm->getEndianness(), varSize);
 		SavePartVars vars(_vm, varSize);
 
-		delete[] slotFile;
-
 		// Write the description
 		info.setDesc(_index + (slot * kSlotNameLength), kSlotNameLength);
 		// Write all variables

Modified: scummvm/trunk/engines/gob/save/saveload_v3.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveload_v3.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveload_v3.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -302,9 +302,9 @@
 		return (_reader != 0);
 
 	if (!_reader || (_reader->getSlot() != ((uint32) slot))) {
-		char *slotFile = _slotFile->build(slot);
+		Common::String slotFile = _slotFile->build(slot);
 		
-		if (!slotFile)
+		if (slotFile.empty())
 			return false;
 
 		delete _reader;
@@ -313,7 +313,6 @@
 		if (converter.isOldSave()) {
 			// Old save, plug the converter in
 			if (!converter.load()) {
-				delete[] slotFile;
 				return false;
 			}
 
@@ -322,8 +321,6 @@
 		} else
 			_reader = new SaveReader(_usesScreenshots ? 3 : 2, slot, slotFile);
 		
-		delete[] slotFile;
-
 		if (!_reader->load()) {
 			delete _reader;
 			_reader = 0;
@@ -340,15 +337,13 @@
 		return (_writer != 0);
 
 	if (!_writer || (_writer->getSlot() != ((uint32) slot))) {
-		char *slotFile = _slotFile->build(slot);
+		Common::String slotFile = _slotFile->build(slot);
 		
-		if (!slotFile)
+		if (slotFile.empty())
 			return false;
 
 		delete _writer;
 		_writer = new SaveWriter(_usesScreenshots ? 3 : 2, slot, slotFile);
-		
-		delete[] slotFile;
 	}
 
 	return true;
@@ -378,15 +373,13 @@
 	Common::InSaveFile *in;
 
 	for (uint32 i = 0; i < _slotCount; i++, buffer++) {
-		char *slotFile = build(i);
+		Common::String slotFile = build(i);
 
-		if (slotFile && ((in = saveMan->openForLoading(slotFile)))) {
+		if (!slotFile.empty() && ((in = saveMan->openForLoading(slotFile)))) {
 			delete in;
 			*buffer = 1;
 		} else
 			*buffer = 0;
-
-		delete[] slotFile;
 	}
 }
 

Modified: scummvm/trunk/engines/gob/save/saveload_v4.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveload_v4.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveload_v4.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -317,9 +317,9 @@
 		return (_reader != 0);
 
 	if (!_reader || (_reader->getSlot() != ((uint32) slot))) {
-		char *slotFile = _slotFile->build(slot);
+		Common::String slotFile = _slotFile->build(slot);
 		
-		if (!slotFile)
+		if (slotFile.empty())
 			return false;
 
 		delete _reader;
@@ -328,7 +328,6 @@
 		if (converter.isOldSave()) {
 			// Old save, plug the converter in
 			if (!converter.load()) {
-				delete[] slotFile;
 				return false;
 			}
 
@@ -337,8 +336,6 @@
 		} else
 			_reader = new SaveReader(3, slot, slotFile);
 		
-		delete[] slotFile;
-
 		if (!_reader->load()) {
 			delete _reader;
 			_reader = 0;
@@ -355,15 +352,13 @@
 		return (_writer != 0);
 
 	if (!_writer || (_writer->getSlot() != ((uint32) slot))) {
-		char *slotFile = _slotFile->build(slot);
+		Common::String slotFile = _slotFile->build(slot);
 		
-		if (!slotFile)
+		if (slotFile.empty())
 			return false;
 
 		delete _writer;
 		_writer = new SaveWriter(3, slot, slotFile);
-		
-		delete[] slotFile;
 	}
 
 	return true;

Modified: scummvm/trunk/engines/gob/save/saveload_v6.cpp
===================================================================
--- scummvm/trunk/engines/gob/save/saveload_v6.cpp	2009-05-31 17:00:07 UTC (rev 41078)
+++ scummvm/trunk/engines/gob/save/saveload_v6.cpp	2009-05-31 17:00:38 UTC (rev 41079)
@@ -134,7 +134,7 @@
 			return false;
 		}
 
-		char *slotFile = _slotFile->build(slot);
+		Common::String slotFile = _slotFile->build(slot);
 
 		SaveReader *reader = 0;
 		SaveConverter_v6 converter(_vm, slotFile);
@@ -159,8 +159,6 @@
 			return false;
 		}
 
-		delete[] slotFile;
-
 		if (!reader->readPart(0, &info)) {
 			delete reader;
 			return false;
@@ -233,15 +231,13 @@
 			return false;
 		}
 
-		char *slotFile = _slotFile->build(slot);
+		Common::String slotFile = _slotFile->build(slot);
 
 		SaveWriter writer(2, slot, slotFile);
 		SavePartInfo info(kSlotNameLength, (uint32) _vm->getGameType(), 0,
 				_vm->getEndianness(), varSize);
 		SavePartVars vars(_vm, varSize);
 
-		delete[] slotFile;
-
 		// Write the description
 		info.setDesc(_index + (slot * kSlotNameLength), kSlotNameLength);
 		// Write all variables


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