[Scummvm-cvs-logs] CVS: scummvm/sword1 control.cpp,1.33,1.34
Max Horn
fingolfin at users.sourceforge.net
Fri Jun 25 15:14:01 CEST 2004
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common system.cpp,1.11,1.12 system.h,1.67,1.68 savefile.h,1.10,1.11 savefile.cpp,1.10,1.11
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sword2 save_rest.cpp,1.55,1.56
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /cvsroot/scummvm/scummvm/sword1
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9054/sword1
Modified Files:
control.cpp
Log Message:
Use auto_ptr to avoid leaks
Index: control.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword1/control.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- control.cpp 12 May 2004 06:21:44 -0000 1.33
+++ control.cpp 25 Jun 2004 22:12:56 -0000 1.34
@@ -37,6 +37,8 @@
#include "sword1/sworddefs.h"
#include "sword1/swordres.h"
+#include <memory>
+
namespace Sword1 {
#define SAVEFILE_WRITE true
@@ -665,7 +667,8 @@
}
void Control::readSavegameDescriptions(void) {
- SaveFileManager *mgr = _system->get_savefile_manager();
+ const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
+
SaveFile *inf;
inf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
_saveScrollPos = _saveFiles = 0;
@@ -692,7 +695,6 @@
for (uint8 cnt = 0; cnt < 64; cnt++)
_saveNames[cnt][0] = '\0';
delete inf;
- delete mgr;
}
int Control::displayMessage(const char *altButton, const char *message, ...) {
@@ -712,7 +714,8 @@
}
void Control::writeSavegameDescriptions(void) {
- SaveFileManager *mgr = _system->get_savefile_manager();
+ const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
+
SaveFile *outf;
outf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_WRITE);
@@ -734,18 +737,17 @@
outf->writeByte(255);
}
delete outf;
- delete mgr;
}
bool Control::savegamesExist(void) {
bool retVal = false;
- SaveFileManager *mgr = _system->get_savefile_manager();
+ const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
+
SaveFile *inf;
inf = mgr->open_savefile("SAVEGAME.INF", _savePath, SAVEFILE_READ);
if (inf && inf->isOpen())
retVal = true;
delete inf;
- delete mgr;
return retVal;
}
@@ -898,7 +900,8 @@
uint16 cnt;
sprintf(fName, "SAVEGAME.%03d", slot);
uint16 liveBuf[TOTAL_SECTIONS];
- SaveFileManager *mgr = _system->get_savefile_manager();
+ const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
+
SaveFile *outf;
outf = mgr->open_savefile(fName, _savePath, SAVEFILE_WRITE);
if (!outf || !outf->isOpen()) {
@@ -926,20 +929,19 @@
for (uint32 cnt2 = 0; cnt2 < playerSize; cnt2++)
outf->writeUint32LE(playerRaw[cnt2]);
delete outf;
- delete mgr;
}
bool Control::restoreGameFromFile(uint8 slot) {
char fName[15];
uint16 cnt;
sprintf(fName, "SAVEGAME.%03d", slot);
- SaveFileManager *mgr = _system->get_savefile_manager();
+ const std::auto_ptr<SaveFileManager> mgr(_system->get_savefile_manager());
+
SaveFile *inf;
inf = mgr->open_savefile(fName, _savePath, SAVEFILE_READ);
if (!inf || !inf->isOpen()) {
// Display an error message, and do nothing
displayMessage(0, "Can't open file '%s' in directory '%s'", fName, _savePath);
- delete mgr;
return false;
}
@@ -963,7 +965,6 @@
playerBuf[cnt2] = inf->readUint32LE();
delete inf;
- delete mgr;
return true;
}
- Previous message: [Scummvm-cvs-logs] CVS: scummvm/common system.cpp,1.11,1.12 system.h,1.67,1.68 savefile.h,1.10,1.11 savefile.cpp,1.10,1.11
- Next message: [Scummvm-cvs-logs] CVS: scummvm/sword2 save_rest.cpp,1.55,1.56
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the Scummvm-git-logs
mailing list