aboutsummaryrefslogtreecommitdiff
path: root/engines/gob
diff options
context:
space:
mode:
Diffstat (limited to 'engines/gob')
-rw-r--r--engines/gob/helper.h30
-rw-r--r--engines/gob/save/saveconverter.cpp4
-rw-r--r--engines/gob/save/saveconverter.h12
-rw-r--r--engines/gob/save/saveconverter_v2.cpp2
-rw-r--r--engines/gob/save/saveconverter_v3.cpp2
-rw-r--r--engines/gob/save/saveconverter_v4.cpp2
-rw-r--r--engines/gob/save/saveconverter_v6.cpp2
-rw-r--r--engines/gob/save/savehandler.cpp133
-rw-r--r--engines/gob/save/savehandler.h25
-rw-r--r--engines/gob/save/saveload_v2.cpp8
-rw-r--r--engines/gob/save/saveload_v3.cpp19
-rw-r--r--engines/gob/save/saveload_v4.cpp13
-rw-r--r--engines/gob/save/saveload_v6.cpp8
13 files changed, 92 insertions, 168 deletions
diff --git a/engines/gob/helper.h b/engines/gob/helper.h
index 5bedf81014..fbb5ae7ec8 100644
--- a/engines/gob/helper.h
+++ b/engines/gob/helper.h
@@ -35,36 +35,6 @@ inline char *strncpy0(char *dest, const char *src, size_t n) {
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 {
diff --git a/engines/gob/save/saveconverter.cpp b/engines/gob/save/saveconverter.cpp
index 06fb2a53e9..8c6d4ca04f 100644
--- a/engines/gob/save/saveconverter.cpp
+++ b/engines/gob/save/saveconverter.cpp
@@ -72,7 +72,7 @@ void SaveConverter::displayWarning() const {
"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 @@ bool SaveConverter::seek(int32 offset, int whence) {
SaveConverter_Notes::SaveConverter_Notes(GobEngine *vm, uint32 notesSize,
- const char *fileName) : SaveConverter(vm, fileName) {
+ const Common::String &fileName) : SaveConverter(vm, fileName) {
_size = notesSize;
}
diff --git a/engines/gob/save/saveconverter.h b/engines/gob/save/saveconverter.h
index 96708c5543..3ae48e1edc 100644
--- a/engines/gob/save/saveconverter.h
+++ b/engines/gob/save/saveconverter.h
@@ -56,7 +56,7 @@ public:
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 @@ private:
/** 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 @@ private:
/** 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 @@ private:
/** 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 @@ private:
/** 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 @@ private:
/** 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;
diff --git a/engines/gob/save/saveconverter_v2.cpp b/engines/gob/save/saveconverter_v2.cpp
index 96ed949753..64770256e5 100644
--- a/engines/gob/save/saveconverter_v2.cpp
+++ b/engines/gob/save/saveconverter_v2.cpp
@@ -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) {
}
diff --git a/engines/gob/save/saveconverter_v3.cpp b/engines/gob/save/saveconverter_v3.cpp
index d707268d9c..9be980249a 100644
--- a/engines/gob/save/saveconverter_v3.cpp
+++ b/engines/gob/save/saveconverter_v3.cpp
@@ -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) {
}
diff --git a/engines/gob/save/saveconverter_v4.cpp b/engines/gob/save/saveconverter_v4.cpp
index 23273446d1..5096a159e4 100644
--- a/engines/gob/save/saveconverter_v4.cpp
+++ b/engines/gob/save/saveconverter_v4.cpp
@@ -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) {
}
diff --git a/engines/gob/save/saveconverter_v6.cpp b/engines/gob/save/saveconverter_v6.cpp
index 01818e8191..ea2c7d1e06 100644
--- a/engines/gob/save/saveconverter_v6.cpp
+++ b/engines/gob/save/saveconverter_v6.cpp
@@ -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) {
}
diff --git a/engines/gob/save/savehandler.cpp b/engines/gob/save/savehandler.cpp
index 965ddea4b3..74b878f0a1 100644
--- a/engines/gob/save/savehandler.cpp
+++ b/engines/gob/save/savehandler.cpp
@@ -37,17 +37,12 @@
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 {
@@ -56,13 +51,12 @@ uint32 SlotFileIndexed::getSlotMax() const {
// 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 @@ void SlotFileIndexed::buildIndex(byte *buffer, SavePartInfo &info,
// 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 @@ void SlotFileIndexed::buildIndex(byte *buffer, SavePartInfo &info,
} else
// No valid slot, fill with 0
memset(buffer, 0, descLength);
-
- delete[] slotFile;
}
}
@@ -121,85 +113,51 @@ bool SlotFileIndexed::exists(int slot) const {
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)
- 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)
+ 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::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;
-
- size_t len = strlen(_base) + strlen(_ext) + 4;
+ return Common::String();
- char *slotFile = new char[len];
+ char buf[4];
+ snprintf(buf, sizeof(buf), "%02d", slot);
- 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,8 +168,33 @@ int SlotFileStatic::getSlotRemainder(int32 offset) const {
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;
}
@@ -357,14 +340,14 @@ bool TempSpriteHandler::usesPalette(int32 size) {
}
-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 @@ NotesHandler::~NotesHandler() {
}
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 @@ int32 NotesHandler::getSize() {
SaveReader reader(1, 0, fileName);
SaveHeader header;
- delete[] fileName;
-
if (!reader.load())
return -1;
@@ -416,9 +397,9 @@ bool NotesHandler::load(int16 dataVar, int32 size, int32 offset) {
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 @@ bool NotesHandler::load(int16 dataVar, int32 size, int32 offset) {
SavePartVars vars(_vm, _notesSize);
- delete[] fileName;
-
if (!reader->load()) {
delete reader;
return false;
@@ -462,16 +441,14 @@ bool NotesHandler::save(int16 dataVar, int32 size, int32 offset) {
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;
diff --git a/engines/gob/save/savehandler.h b/engines/gob/save/savehandler.h
index 7ddb4c2711..cb984f7abb 100644
--- a/engines/gob/save/savehandler.h
+++ b/engines/gob/save/savehandler.h
@@ -45,12 +45,9 @@ public:
* @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 @@ public:
protected:
GobEngine *_vm;
- char *_base;
+ Common::String _base;
uint32 _slotCount;
};
@@ -66,12 +63,12 @@ protected:
/** 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 @@ public:
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 @@ protected:
/** 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 @@ public:
private:
class File : public SlotFileStatic {
public:
- File(GobEngine *vm, const char *base);
+ File(GobEngine *vm, const Common::String &base);
~File();
};
diff --git a/engines/gob/save/saveload_v2.cpp b/engines/gob/save/saveload_v2.cpp
index 0bbefe28db..496b45ac41 100644
--- a/engines/gob/save/saveload_v2.cpp
+++ b/engines/gob/save/saveload_v2.cpp
@@ -124,7 +124,7 @@ bool SaveLoad_v2::GameHandler::load(int16 dataVar, int32 size, int32 offset) {
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 @@ bool SaveLoad_v2::GameHandler::load(int16 dataVar, int32 size, int32 offset) {
return false;
}
- delete[] slotFile;
-
if (!reader->readPart(0, &info)) {
delete reader;
return false;
@@ -220,15 +218,13 @@ bool SaveLoad_v2::GameHandler::save(int16 dataVar, int32 size, int32 offset) {
_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
diff --git a/engines/gob/save/saveload_v3.cpp b/engines/gob/save/saveload_v3.cpp
index 665e925b00..5686838230 100644
--- a/engines/gob/save/saveload_v3.cpp
+++ b/engines/gob/save/saveload_v3.cpp
@@ -302,9 +302,9 @@ bool SaveLoad_v3::GameHandler::createReader(int slot) {
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 @@ bool SaveLoad_v3::GameHandler::createReader(int slot) {
if (converter.isOldSave()) {
// Old save, plug the converter in
if (!converter.load()) {
- delete[] slotFile;
return false;
}
@@ -322,8 +321,6 @@ bool SaveLoad_v3::GameHandler::createReader(int slot) {
} else
_reader = new SaveReader(_usesScreenshots ? 3 : 2, slot, slotFile);
- delete[] slotFile;
-
if (!_reader->load()) {
delete _reader;
_reader = 0;
@@ -340,15 +337,13 @@ bool SaveLoad_v3::GameHandler::createWriter(int slot) {
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 @@ void SaveLoad_v3::ScreenshotHandler::File::buildIndex(byte *buffer) const {
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;
}
}
diff --git a/engines/gob/save/saveload_v4.cpp b/engines/gob/save/saveload_v4.cpp
index e73b745aae..d626c71ad4 100644
--- a/engines/gob/save/saveload_v4.cpp
+++ b/engines/gob/save/saveload_v4.cpp
@@ -317,9 +317,9 @@ bool SaveLoad_v4::GameHandler::createReader(int slot) {
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 @@ bool SaveLoad_v4::GameHandler::createReader(int slot) {
if (converter.isOldSave()) {
// Old save, plug the converter in
if (!converter.load()) {
- delete[] slotFile;
return false;
}
@@ -337,8 +336,6 @@ bool SaveLoad_v4::GameHandler::createReader(int slot) {
} else
_reader = new SaveReader(3, slot, slotFile);
- delete[] slotFile;
-
if (!_reader->load()) {
delete _reader;
_reader = 0;
@@ -355,15 +352,13 @@ bool SaveLoad_v4::GameHandler::createWriter(int slot) {
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;
diff --git a/engines/gob/save/saveload_v6.cpp b/engines/gob/save/saveload_v6.cpp
index 455137aa6a..ac2a626521 100644
--- a/engines/gob/save/saveload_v6.cpp
+++ b/engines/gob/save/saveload_v6.cpp
@@ -134,7 +134,7 @@ bool SaveLoad_v6::GameHandler::load(int16 dataVar, int32 size, int32 offset) {
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 @@ bool SaveLoad_v6::GameHandler::load(int16 dataVar, int32 size, int32 offset) {
return false;
}
- delete[] slotFile;
-
if (!reader->readPart(0, &info)) {
delete reader;
return false;
@@ -233,15 +231,13 @@ bool SaveLoad_v6::GameHandler::save(int16 dataVar, int32 size, int32 offset) {
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