[Scummvm-cvs-logs] SF.net SVN: scummvm:[53956] scummvm/trunk/engines/hugo

strangerke at users.sourceforge.net strangerke at users.sourceforge.net
Sat Oct 30 22:48:54 CEST 2010


Revision: 53956
          http://scummvm.svn.sourceforge.net/scummvm/?rev=53956&view=rev
Author:   strangerke
Date:     2010-10-30 20:48:54 +0000 (Sat, 30 Oct 2010)

Log Message:
-----------
HUGO: Free some more memory before exiting

- suppress two useless variables
- initialize some variables

Modified Paths:
--------------
    scummvm/trunk/engines/hugo/hugo.cpp
    scummvm/trunk/engines/hugo/hugo.h

Modified: scummvm/trunk/engines/hugo/hugo.cpp
===================================================================
--- scummvm/trunk/engines/hugo/hugo.cpp	2010-10-30 19:51:17 UTC (rev 53955)
+++ scummvm/trunk/engines/hugo/hugo.cpp	2010-10-30 20:48:54 UTC (rev 53956)
@@ -66,7 +66,7 @@
 	_arrayNouns(0), _arrayVerbs(0), _arrayReqs(0), _hotspots(0), _invent(0), _uses(0), _catchallList(0), _backgroundObjects(0),
 	_points(0), _cmdList(0), _screenActs(0), _actListArr(0), _heroImage(0), _defltTunes(0), _palette(0), _introX(0), _introY(0),
 	_maxInvent(0), _numBonuses(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), _screenStates(0), _numObj(0),
-	_score(0), _maxscore(0)
+	_score(0), _maxscore(0), _backgroundObjectsSize(0), _screenActsSize(0), _actListArrSize(0), _usesSize(0)
 
 {
 	DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level");
@@ -84,18 +84,8 @@
 }
 
 HugoEngine::~HugoEngine() {
-	free(_palette);
-	free(_introX);
-	free(_introY);
 	free(_textData);
 	free(_stringtData);
-	free(_screenNames);
-	free(_textEngine);
-	free(_textIntro);
-	free(_textMouse);
-	free(_textParser);
-	free(_textSchedule);
-	free(_textUtil);
 
 	for (int i = 0; _arrayNouns[i]; i++)
 		free(_arrayNouns[i]);
@@ -105,10 +95,24 @@
 		free(_arrayVerbs[i]);
 	free(_arrayVerbs);
 
+	free(_screenNames);
+	free(_palette);
+	free(_textEngine);
+	free(_textIntro);
+	free(_introX);
+	free(_introY);
+	free(_textMouse);
+	free(_textParser);
+	free(_textSchedule);
+	free(_textUtil);
 	free(_arrayReqs);
 	free(_hotspots);
 	free(_invent);
+
+	for (int i = 0; i < _usesSize; i++)
+		free(_uses[i].targets);
 	free(_uses);
+
 	free(_catchallList);
 
 	for (int i = 0; i < _backgroundObjectsSize; i++)
@@ -395,10 +399,10 @@
 	_stringtData = loadTextsVariante(in, 0);
 
 	// Read arrayNouns
-	_arrayNouns = loadTextsArray(in, &_arrayNounsSize);
+	_arrayNouns = loadTextsArray(in);
 
 	// Read arrayVerbs
-	_arrayVerbs = loadTextsArray(in, &_arrayVerbsSize);
+	_arrayVerbs = loadTextsArray(in);
 
 	// Read screenNames
 	_screenNames = loadTextsVariante(in, &_numScreens);
@@ -499,6 +503,7 @@
 	for (int varnt = 0; varnt < _numVariant; varnt++) {
 		numElem = in.readUint16BE();
 		if (varnt == _gameVariant) {
+			_usesSize = numElem;
 			_uses = (uses_t *)malloc(sizeof(uses_t) * numElem);
 			for (int i = 0; i < numElem; i++) {
 				_uses[i].objId = in.readSint16BE();
@@ -1387,16 +1392,17 @@
 	return resArray;
 }
 
-char ***HugoEngine::loadTextsArray(Common::File &in, uint16 *arraySize) {
+char ***HugoEngine::loadTextsArray(Common::File &in) {
 	char ***resArray = 0;
+	uint16 arraySize;
 
 	for (int varnt = 0; varnt < _numVariant; varnt++) {
-		*arraySize = in.readUint16BE();
+		arraySize = in.readUint16BE();
 		if (varnt == _gameVariant) {
-			resArray = (char ***)malloc(sizeof(char **) * (*arraySize + 1));
-			resArray[*arraySize] = 0;
+			resArray = (char ***)malloc(sizeof(char **) * (arraySize + 1));
+			resArray[arraySize] = 0;
 		}
-		for (int i = 0; i < *arraySize; i++) {
+		for (int i = 0; i < arraySize; i++) {
 			int numTexts = in.readUint16BE();
 			int entryLen = in.readUint16BE();
 			char *pos = (char *)malloc(entryLen);

Modified: scummvm/trunk/engines/hugo/hugo.h
===================================================================
--- scummvm/trunk/engines/hugo/hugo.h	2010-10-30 19:51:17 UTC (rev 53955)
+++ scummvm/trunk/engines/hugo/hugo.h	2010-10-30 20:48:54 UTC (rev 53956)
@@ -139,13 +139,12 @@
 	char  **_textSchedule;
 	char  **_textUtil;
 	char  ***_arrayNouns;
-	uint16 _arrayNounsSize;
 	char  ***_arrayVerbs;
-	uint16 _arrayVerbsSize;
 	uint16    **_arrayReqs;
 	hotspot_t *_hotspots;
 	int16     *_invent;
 	uses_t    *_uses;
+	uint16     _usesSize;
 	background_t *_catchallList;
 	background_t **_backgroundObjects;
 	uint16    _backgroundObjectsSize;
@@ -293,7 +292,7 @@
 	int _maxscore;                      // Holds maximum score
 
 	char **loadTextsVariante(Common::File &in, uint16 *arraySize);
-	char ***loadTextsArray(Common::File &in, uint16 *arraySize);
+	char ***loadTextsArray(Common::File &in);
 	uint16 **loadLongArray(Common::File &in);
 	char **loadTexts(Common::File &in);
 	void freeTexts(char **ptr);


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list