aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMax Horn2002-10-23 12:56:30 +0000
committerMax Horn2002-10-23 12:56:30 +0000
commit4625c126c61472508288600da6f75c5873ba37d8 (patch)
tree4f22355a8190d73caea7740befafe66ab8930cd4
parent71e6b038837da7776b3a68c920ad9e9077196c17 (diff)
downloadscummvm-rg350-4625c126c61472508288600da6f75c5873ba37d8.tar.gz
scummvm-rg350-4625c126c61472508288600da6f75c5873ba37d8.tar.bz2
scummvm-rg350-4625c126c61472508288600da6f75c5873ba37d8.zip
don't use strdup
svn-id: r5287
-rw-r--r--common/gameDetector.cpp15
-rw-r--r--common/gameDetector.h4
-rw-r--r--common/main.cpp2
3 files changed, 10 insertions, 11 deletions
diff --git a/common/gameDetector.cpp b/common/gameDetector.cpp
index fd5f57f657..7b0cf22dca 100644
--- a/common/gameDetector.cpp
+++ b/common/gameDetector.cpp
@@ -94,7 +94,6 @@ GameDetector::GameDetector()
_gameDataPath = 0;
_gameTempo = 0;
_midi_driver = MD_AUTO;
- _gameText = 0;
_features = 0;
_cdrom = 0;
@@ -520,7 +519,7 @@ bool GameDetector::detectGame()
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 @@ bool GameDetector::detectGame()
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 @@ int GameDetector::detectMain()
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] != ':'
diff --git a/common/gameDetector.h b/common/gameDetector.h
index f40441ada1..0e10f62484 100644
--- a/common/gameDetector.h
+++ b/common/gameDetector.h
@@ -49,7 +49,7 @@ public:
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 @@ public:
int _gameTempo;
int _midi_driver;
String _gameFileName;
- const char *_gameText;
+ String _gameText;
uint32 _features;
int _gfx_driver;
diff --git a/common/main.cpp b/common/main.cpp
index 802e789c6d..fa76617bc1 100644
--- a/common/main.cpp
+++ b/common/main.cpp
@@ -191,7 +191,7 @@ int main(int argc, char *argv[])
// 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