aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Montoir2006-11-03 21:01:49 +0000
committerGregory Montoir2006-11-03 21:01:49 +0000
commitf9cf368a670ee58b579da8affca914e0b5634d8c (patch)
tree912962b56d37a0d66b367458ba69e6dd90079e27
parente57316c7965ee6518c167328523ceb8e50dfe6e3 (diff)
downloadscummvm-rg350-f9cf368a670ee58b579da8affca914e0b5634d8c.tar.gz
scummvm-rg350-f9cf368a670ee58b579da8affca914e0b5634d8c.tar.bz2
scummvm-rg350-f9cf368a670ee58b579da8affca914e0b5634d8c.zip
got rid of two memory leaks
svn-id: r24589
-rw-r--r--common/advancedDetector.cpp15
-rw-r--r--common/advancedDetector.h2
-rw-r--r--engines/agos/game.cpp2
-rw-r--r--engines/cine/detection.cpp1
-rw-r--r--engines/saga/game.cpp2
5 files changed, 8 insertions, 14 deletions
diff --git a/common/advancedDetector.cpp b/common/advancedDetector.cpp
index 9f5fea7fec..3773c54c7a 100644
--- a/common/advancedDetector.cpp
+++ b/common/advancedDetector.cpp
@@ -34,7 +34,7 @@ AdvancedDetector::AdvancedDetector() {
_fileMD5Bytes = 0;
}
-String AdvancedDetector::getDescription(int num) {
+String AdvancedDetector::getDescription(int num) const {
char tmp[256];
const ADGameDescription *g = _gameDescriptions[num];
@@ -67,7 +67,7 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, Language language, Pla
assert(_gameDescriptions.size());
- matched = (int *)malloc(_gameDescriptions.size() * sizeof(int));
+ matched = new int[_gameDescriptions.size()];
// First we compose list of files which we need MD5s for
for (i = 0; i < _gameDescriptions.size(); i++) {
@@ -138,9 +138,8 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, Language language, Pla
if (strcmp(fileDesc->md5, filesMD5[tstr].c_str()) && strcmp(fileDesc->md5, filesMD5[tstr2].c_str())) {
fileMissing = true;
break;
- } else {
- debug(3, "Matched file: %s", tstr.c_str());
}
+ debug(3, "Matched file: %s", tstr.c_str());
}
if (!fileMissing) {
debug(2, "Found game: %s", getDescription(i).c_str());
@@ -183,13 +182,13 @@ ADList AdvancedDetector::detectGame(const FSList *fslist, Language language, Pla
}
- ADList *returnMatches = new ADList;
- j = 0;
+ ADList returnMatches;
for (i = 0; i < matchedCount; i++)
if (matched[i] != -1)
- returnMatches->push_back(matched[i]);
+ returnMatches.push_back(matched[i]);
- return *returnMatches;
+ delete[] matched;
+ return returnMatches;
}
} // End of namespace Common
diff --git a/common/advancedDetector.h b/common/advancedDetector.h
index c800a34db5..6d7ce23e3b 100644
--- a/common/advancedDetector.h
+++ b/common/advancedDetector.h
@@ -79,7 +79,7 @@ private:
int _fileMD5Bytes;
- String getDescription(int num);
+ String getDescription(int num) const;
};
} // End of namespace Common
diff --git a/engines/agos/game.cpp b/engines/agos/game.cpp
index 9cf545f5b9..55fa425a5a 100644
--- a/engines/agos/game.cpp
+++ b/engines/agos/game.cpp
@@ -219,8 +219,6 @@ bool AGOSEngine::initGame() {
}
}
- //delete &matches;
-
if (gameNumber >= ARRAYSIZE(gameDescriptions) || gameNumber == -1) {
error("AGOSEngine::loadGame wrong gameNumber");
}
diff --git a/engines/cine/detection.cpp b/engines/cine/detection.cpp
index 4bda1d9991..d56d85481d 100644
--- a/engines/cine/detection.cpp
+++ b/engines/cine/detection.cpp
@@ -706,7 +706,6 @@ DetectedGameList GAME_detectGames(const FSList &fslist) {
for (uint i = 0; i < matches.size(); i++)
detectedGames.push_back(toDetectedGame(gameDescriptions[matches[i]].desc));
- //delete &matches;
return detectedGames;
}
diff --git a/engines/saga/game.cpp b/engines/saga/game.cpp
index f3f8e1629f..31654eba9a 100644
--- a/engines/saga/game.cpp
+++ b/engines/saga/game.cpp
@@ -153,8 +153,6 @@ bool SagaEngine::initGame() {
gameNumber = matches[0];
- //delete matches;
-
if (gameNumber >= gameCount || gameNumber == -1) {
error("SagaEngine::loadGame wrong gameNumber");
}