[Scummvm-cvs-logs] SF.net SVN: scummvm: [27007] scummvm/trunk/engines/cine

cyx at users.sourceforge.net cyx at users.sourceforge.net
Tue May 29 23:06:08 CEST 2007


Revision: 27007
          http://scummvm.svn.sourceforge.net/scummvm/?rev=27007&view=rev
Author:   cyx
Date:     2007-05-29 14:06:07 -0700 (Tue, 29 May 2007)

Log Message:
-----------
removed some resource related memory leaks

Modified Paths:
--------------
    scummvm/trunk/engines/cine/anim.cpp
    scummvm/trunk/engines/cine/bg.cpp
    scummvm/trunk/engines/cine/msg.cpp
    scummvm/trunk/engines/cine/object.cpp
    scummvm/trunk/engines/cine/prc.cpp
    scummvm/trunk/engines/cine/rel.cpp

Modified: scummvm/trunk/engines/cine/anim.cpp
===================================================================
--- scummvm/trunk/engines/cine/anim.cpp	2007-05-29 20:22:20 UTC (rev 27006)
+++ scummvm/trunk/engines/cine/anim.cpp	2007-05-29 21:06:07 UTC (rev 27007)
@@ -416,6 +416,8 @@
 	animDataTable[entry].fileIdx = foundFileIdx;
 	animDataTable[entry].frameIdx = 0;
 	strcpy(animDataTable[entry].name, currentPartName);
+
+	free(dataPtr);
 }
 
 void loadSplAbs(const char *resourceName, uint16 idx) {
@@ -428,6 +430,8 @@
 
 	entry = reserveFrame((uint16) partBuffer[foundFileIdx].unpackedSize, 1, 0, idx);
 	memcpy(animDataTable[entry].ptr1, dataPtr, partBuffer[foundFileIdx].unpackedSize);
+
+	free(dataPtr);
 }
 
 void loadMsk(const char *resourceName) {
@@ -475,6 +479,8 @@
 		animDataTable[entry].frameIdx = i;
 		strcpy(animDataTable[entry].name, currentPartName);
 	}
+
+	free(dataPtr);
 }
 
 void loadAni(const char *resourceName) {
@@ -555,6 +561,8 @@
 		animDataTable[entry].frameIdx = i;
 		strcpy(animDataTable[entry].name, currentPartName);
 	}
+
+	free(dataPtr);
 }
 
 void convert8BBP(byte * dest, byte * source, int16 width, int16 height) {
@@ -754,6 +762,8 @@
 		animDataTable[entry].frameIdx = i;
 		strcpy(animDataTable[entry].name, currentPartName);
 	}
+
+	free(dataPtr);
 }
 
 void loadSetAbs(const char *resourceName, uint16 idx) {
@@ -841,6 +851,8 @@
 		animDataTable[entry].frameIdx = i;
 		strcpy(animDataTable[entry].name, currentPartName);
 	}
+
+	free(dataPtr);
 }
 
 void loadSeq(const char *resourceName) {
@@ -854,6 +866,8 @@
 	entry = allocFrame2((uint16) partBuffer[foundFileIdx].unpackedSize, 1, 0);
 
 	memcpy(animDataTable[entry].ptr1, dataPtr + 0x16, (uint16) partBuffer[foundFileIdx].unpackedSize - 0x16);
+
+	free(dataPtr);
 }
 
 void loadSeqAbs(const char *resourceName, uint16 idx) {
@@ -867,6 +881,8 @@
 	entry = reserveFrame((uint16) partBuffer[foundFileIdx].unpackedSize, 1, 0, idx);
 
 	memcpy(animDataTable[entry].ptr1, dataPtr + 0x16, (uint16) partBuffer[foundFileIdx].unpackedSize - 0x16);
+
+	free(dataPtr);
 }
 
 void loadResource(const char *resourceName) {
@@ -1060,6 +1076,7 @@
 				}
 			}
 
+			free(dataPtr);
 		}
 	}
 

Modified: scummvm/trunk/engines/cine/bg.cpp
===================================================================
--- scummvm/trunk/engines/cine/bg.cpp	2007-05-29 20:22:20 UTC (rev 27006)
+++ scummvm/trunk/engines/cine/bg.cpp	2007-05-29 21:06:07 UTC (rev 27007)
@@ -39,10 +39,11 @@
 
 byte loadCt(const char *ctName) {
 	uint16 header[32];
+	byte *ptr, *dataPtr;
 
 	strcpy(currentCtName, ctName);
 
-	byte *ptr = readBundleFile(findFileInBundle(ctName));
+	ptr = dataPtr = readBundleFile(findFileInBundle(ctName));
 
 	if (g_cine->getGameType() == Cine::GType_OS) {
 		uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;
@@ -68,6 +69,7 @@
 		gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200);
 	}
 
+	free(dataPtr);
 	return 0;
 }
 
@@ -81,10 +83,12 @@
 }
 
 byte loadBg(const char *bgName) {
+	byte *ptr, *dataPtr;
+
 	strcpy(currentBgName[0], bgName);
 
 	byte fileIdx = findFileInBundle(bgName);
-	byte *ptr = readBundleFile(fileIdx);
+	ptr = dataPtr = readBundleFile(fileIdx);
 
 	uint16 bpp = READ_BE_UINT16(ptr); ptr += 2;
 	if (bpp == 8) {
@@ -102,6 +106,7 @@
 		gfxResetRawPage(page2Raw);
 		gfxConvertSpriteToRaw(page2Raw, ptr, 160, 200);
 	}
+	free(dataPtr);
 	return 0;
 }
 
@@ -110,10 +115,12 @@
 byte currentAdditionalBgIdx2 = 0;
 
 void addBackground(const char *bgName, uint16 bgIdx) {
+	byte *ptr, *dataPtr;
+
 	strcpy(currentBgName[bgIdx], bgName);
 
 	byte fileIdx = findFileInBundle(bgName);
-	byte *ptr = readBundleFile(fileIdx);
+	ptr = dataPtr = readBundleFile(fileIdx);
 
 	additionalBgTable[bgIdx] = (byte *) malloc(320 * 200);
 
@@ -125,6 +132,7 @@
 		ptr += 32;
 		gfxConvertSpriteToRaw(additionalBgTable[bgIdx], ptr, 160, 200);
 	}
+	free(dataPtr);
 }
 
 } // End of namespace Cine

Modified: scummvm/trunk/engines/cine/msg.cpp
===================================================================
--- scummvm/trunk/engines/cine/msg.cpp	2007-05-29 20:22:20 UTC (rev 27006)
+++ scummvm/trunk/engines/cine/msg.cpp	2007-05-29 21:06:07 UTC (rev 27007)
@@ -34,7 +34,7 @@
 
 void loadMsg(char *pMsgName) {
 	uint16 i;
-	byte *ptr;
+	byte *ptr, *dataPtr;
 
 	checkDataDisk(-1);
 
@@ -45,14 +45,13 @@
 
 		if (messageTable[i].ptr) {
 			assert(messageTable[i].ptr);
-
 			free(messageTable[i].ptr);
 		}
 
 		messageTable[i].ptr = NULL;
 	}
 
-	ptr = readBundleFile(findFileInBundle(pMsgName));
+	ptr = dataPtr = readBundleFile(findFileInBundle(pMsgName));
 
 	setMouseCursor(MOUSE_CURSOR_DISK);
 
@@ -74,6 +73,8 @@
 			ptr += messageTable[i].len;
 		}
 	}
+
+	free(dataPtr);
 }
 
 } // End of namespace Cine

Modified: scummvm/trunk/engines/cine/object.cpp
===================================================================
--- scummvm/trunk/engines/cine/object.cpp	2007-05-29 20:22:20 UTC (rev 27006)
+++ scummvm/trunk/engines/cine/object.cpp	2007-05-29 21:06:07 UTC (rev 27007)
@@ -61,11 +61,11 @@
 	uint16 numEntry;
 	uint16 entrySize;
 	uint16 i;
-	byte *ptr;
+	byte *ptr, *dataPtr;
 
 	checkDataDisk(-1);
 
-	ptr = readBundleFile(findFileInBundle(pObjectName));
+	ptr = dataPtr = readBundleFile(findFileInBundle(pObjectName));
 
 	setMouseCursor(MOUSE_CURSOR_DISK);
 
@@ -95,6 +95,8 @@
 			objectTable[i].costume = 0;
 		}
 	}
+
+	free(dataPtr);
 }
 
 int8 removeOverlayElement(uint16 objIdx, uint16 param) {

Modified: scummvm/trunk/engines/cine/prc.cpp
===================================================================
--- scummvm/trunk/engines/cine/prc.cpp	2007-05-29 20:22:20 UTC (rev 27006)
+++ scummvm/trunk/engines/cine/prc.cpp	2007-05-29 21:06:07 UTC (rev 27007)
@@ -63,7 +63,7 @@
 void loadPrc(const char *pPrcName) {
 	byte i;
 	uint16 numScripts;
-	const byte *scriptPtr;
+	byte *scriptPtr, *dataPtr;
 
 	assert(pPrcName);
 
@@ -85,9 +85,9 @@
 	checkDataDisk(-1);
 	if ((g_cine->getGameType() == Cine::GType_FW) &&
 		(!scumm_stricmp(pPrcName, BOOT_PRC_NAME) || !scumm_stricmp(pPrcName, "demo.prc"))) {
-		scriptPtr = readFile(pPrcName);
+		scriptPtr = dataPtr = readFile(pPrcName);
 	} else {
-		scriptPtr = readBundleFile(findFileInBundle(pPrcName));
+		scriptPtr = dataPtr = readBundleFile(findFileInBundle(pPrcName));
 	}
 
 	assert(scriptPtr);
@@ -113,6 +113,8 @@
 		}
 	}
 
+	free(dataPtr);
+
 #ifdef DUMP_SCRIPTS
 
 	{

Modified: scummvm/trunk/engines/cine/rel.cpp
===================================================================
--- scummvm/trunk/engines/cine/rel.cpp	2007-05-29 20:22:20 UTC (rev 27006)
+++ scummvm/trunk/engines/cine/rel.cpp	2007-05-29 21:06:07 UTC (rev 27007)
@@ -58,7 +58,7 @@
 void loadRel(char *pRelName) {
 	uint16 numEntry;
 	uint16 i;
-	byte *ptr;
+	byte *ptr, *dataPtr;
 
 	checkDataDisk(-1);
 
@@ -70,7 +70,7 @@
 		}
 	}
 
-	ptr = readBundleFile(findFileInBundle(pRelName));
+	ptr = dataPtr = readBundleFile(findFileInBundle(pRelName));
 
 	setMouseCursor(MOUSE_CURSOR_DISK);
 
@@ -95,6 +95,8 @@
 			ptr += relTable[i].size;
 		}
 	}
+	
+	free(dataPtr);
 
 #ifdef DUMP_SCRIPTS
 


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