[Scummvm-cvs-logs] CVS: scummvm/common gameDetector.cpp,1.21,1.22 gameDetector.h,1.7,1.8 main.cpp,1.14,1.15

Max Horn fingolfin at users.sourceforge.net
Wed Oct 23 05:57:04 CEST 2002


Update of /cvsroot/scummvm/scummvm/common
In directory usw-pr-cvs1:/tmp/cvs-serv6663

Modified Files:
	gameDetector.cpp gameDetector.h main.cpp 
Log Message:
don't use strdup

Index: gameDetector.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- gameDetector.cpp	23 Oct 2002 11:14:33 -0000	1.21
+++ gameDetector.cpp	23 Oct 2002 12:56:30 -0000	1.22
@@ -94,7 +94,6 @@
 	_gameDataPath = 0;
 	_gameTempo = 0;
 	_midi_driver = MD_AUTO;
-	_gameText = 0;
 	_features = 0;
 
 	_cdrom = 0;
@@ -520,7 +519,7 @@
 	const VersionSettings *gnl = version_settings;
 
 	_gameId = 0;
-	_gameText = NULL;
+	_gameText.clear();
 	do {
 		if (!scumm_stricmp(_gameFileName.c_str(), gnl->filename)) {
 			_gameId = gnl->id;
@@ -538,12 +537,12 @@
 	return false;
 }
 
-const char *GameDetector::getGameName()
+const ScummVM::String& GameDetector::getGameName()
 {
-	if (_gameText == NULL) {
-		char buf[256];
-		sprintf(buf, "Unknown game: \"%s\"", _gameFileName.c_str());
-		_gameText = strdup(buf);
+	if (_gameText.isEmpty()) {
+		_gameText = "Unknown game: \"";
+		_gameText += _gameFileName;
+		_gameText += "\"";
 	}
 	return _gameText;
 }
@@ -570,7 +569,7 @@
 
 	if (!_gameDataPath) {
 		warning("No path was provided. Assuming the data files are in the current directory");
-		_gameDataPath = strdup("");
+		_gameDataPath = "";
 	} else if (_gameDataPath[strlen(_gameDataPath)-1] != '/'
 #ifdef __MORPHOS__
 					&& _gameDataPath[strlen(_gameDataPath)-1] != ':'

Index: gameDetector.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/gameDetector.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- gameDetector.h	23 Oct 2002 10:34:14 -0000	1.7
+++ gameDetector.h	23 Oct 2002 12:56:30 -0000	1.8
@@ -49,7 +49,7 @@
 	void parseCommandLine(int argc, char **argv);
 	int detectMain();
 	void setGame(const String &name);
-	const char *getGameName(void);
+	const String& getGameName(void);
 
 	bool _fullScreen;
 	byte _gameId;
@@ -71,7 +71,7 @@
 	int _gameTempo;
 	int _midi_driver;
 	String _gameFileName;
-	const char *_gameText;
+	String _gameText;
 	uint32 _features;
 
 	int _gfx_driver;

Index: main.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/common/main.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- main.cpp	18 Oct 2002 01:39:24 -0000	1.14
+++ main.cpp	23 Oct 2002 12:56:30 -0000	1.15
@@ -191,7 +191,7 @@
 	
 	// Set the window caption (for OSystems that support it)
 	OSystem::Property prop;
-	prop.caption = (char *)detector.getGameName();
+	prop.caption = detector.getGameName().c_str();
 	system->property(OSystem::PROP_SET_WINDOW_CAPTION, &prop);
 
 	// Create the game engine





More information about the Scummvm-git-logs mailing list