[Scummvm-cvs-logs] SF.net SVN: scummvm: [26905] scummvm/trunk/engines/parallaction

peres001 at users.sourceforge.net peres001 at users.sourceforge.net
Mon May 21 23:06:31 CEST 2007


Revision: 26905
          http://scummvm.svn.sourceforge.net/scummvm/?rev=26905&view=rev
Author:   peres001
Date:     2007-05-21 14:06:30 -0700 (Mon, 21 May 2007)

Log Message:
-----------
Fixed the largest memory leaks.

Modified Paths:
--------------
    scummvm/trunk/engines/parallaction/graphics.cpp
    scummvm/trunk/engines/parallaction/inventory.cpp
    scummvm/trunk/engines/parallaction/inventory.h
    scummvm/trunk/engines/parallaction/location.cpp
    scummvm/trunk/engines/parallaction/parallaction.cpp

Modified: scummvm/trunk/engines/parallaction/graphics.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/graphics.cpp	2007-05-21 19:09:49 UTC (rev 26904)
+++ scummvm/trunk/engines/parallaction/graphics.cpp	2007-05-21 21:06:30 UTC (rev 26905)
@@ -852,6 +852,9 @@
 	delete _fonts[kFontLabel];
 	delete _fonts[kFontMenu];
 
+	freeStaticCnv(_mouseComposedArrow);
+	delete _mouseComposedArrow;
+	
 	return;
 }
 

Modified: scummvm/trunk/engines/parallaction/inventory.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.cpp	2007-05-21 19:09:49 UTC (rev 26904)
+++ scummvm/trunk/engines/parallaction/inventory.cpp	2007-05-21 21:06:30 UTC (rev 26905)
@@ -339,6 +339,12 @@
 	_buffer = (byte*)malloc(INVENTORY_WIDTH * INVENTORY_HEIGHT);
 }
 
+void destroyInventory() {
+	if (_buffer)
+		free(_buffer);
+	_buffer = 0;
+}
+
 void cleanInventory() {
 
 	for (uint16 slot = INVENTORY_FIRST_ITEM; slot < INVENTORY_MAX_ITEMS; slot++) {

Modified: scummvm/trunk/engines/parallaction/inventory.h
===================================================================
--- scummvm/trunk/engines/parallaction/inventory.h	2007-05-21 19:09:49 UTC (rev 26904)
+++ scummvm/trunk/engines/parallaction/inventory.h	2007-05-21 21:06:30 UTC (rev 26905)
@@ -41,6 +41,7 @@
 extern InventoryItem _inventory[];
 
 void initInventory();
+void destroyInventory();
 void openInventory();
 void closeInventory();
 int16 isItemInInventory(int32 v);

Modified: scummvm/trunk/engines/parallaction/location.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/location.cpp	2007-05-21 19:09:49 UTC (rev 26904)
+++ scummvm/trunk/engines/parallaction/location.cpp	2007-05-21 21:06:30 UTC (rev 26905)
@@ -179,9 +179,14 @@
 
 	if (_localFlagNames)
 		delete _localFlagNames;
-	_localFlagNames = new Table(120);
-	_localFlagNames->addData("visited");
-
+	
+	// HACK: prevents leakage. A routine like this
+	// should allocate memory at all, though.
+	if ((_engineFlags & kEngineQuit) == 0) {
+		_localFlagNames = new Table(120);
+		_localFlagNames->addData("visited");
+	}
+		
 	_location._walkNodes.clear();
 
 	// TODO (LIST): helperNode should be rendered useless by the use of a Common::List<>

Modified: scummvm/trunk/engines/parallaction/parallaction.cpp
===================================================================
--- scummvm/trunk/engines/parallaction/parallaction.cpp	2007-05-21 19:09:49 UTC (rev 26904)
+++ scummvm/trunk/engines/parallaction/parallaction.cpp	2007-05-21 21:06:30 UTC (rev 26905)
@@ -140,6 +140,10 @@
 		delete _localFlagNames;
 
 	delete _gfx;
+
+	freeLocation();
+	freeCharacter();
+	destroyInventory();
 }
 
 
@@ -304,7 +308,7 @@
 			break;
 
 		case Common::EVENT_QUIT:
-			_system->quit();
+			_engineFlags |= kEngineQuit;
 			break;
 
 		default:
@@ -334,7 +338,7 @@
 			break;
 
 		if (e.type == Common::EVENT_QUIT) {
-			g_system->quit();
+			_engineFlags |= kEngineQuit;
 			break;
 		}
 


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