[Scummvm-cvs-logs] CVS: scummvm/sword2 resman.cpp,1.117,1.118 sound.cpp,1.65,1.66 sound.h,1.24,1.25

Torbjörn Andersson eriktorbjorn at users.sourceforge.net
Sun Dec 11 00:31:02 CET 2005


Update of /cvsroot/scummvm/scummvm/sword2
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5844

Modified Files:
	resman.cpp sound.cpp sound.h 
Log Message:
Fixed Valgrind memory leak warnings, either by freeing memory on exit or
(in one case) by not allocating file handles dynamically. While this isn't
really necessary at the moment, it makes it easier to find the real memory
leaks, if there are any.


Index: resman.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/resman.cpp,v
retrieving revision 1.117
retrieving revision 1.118
diff -u -d -r1.117 -r1.118
--- resman.cpp	29 Oct 2005 21:24:53 -0000	1.117
+++ resman.cpp	11 Dec 2005 08:30:47 -0000	1.118
@@ -189,6 +189,8 @@
 		_vm->_memory->memFree(res->ptr);
 		res = res->next;
 	}
+	for (int i = 0; i < _totalClusters; i++)
+		free(_resFiles[i].entryTab);
 	free(_resList);
 	free(_resConvTable);
 }

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sound.cpp,v
retrieving revision 1.65
retrieving revision 1.66
diff -u -d -r1.65 -r1.66
--- sound.cpp	3 Nov 2005 07:28:21 -0000	1.65
+++ sound.cpp	11 Dec 2005 08:30:47 -0000	1.66
@@ -53,14 +53,12 @@
 	for (i = 0; i < MAXMUS; i++) {
 		_music[i] = NULL;
 
-		_musicFile[i].file = new Common::File;
 		_musicFile[i].idxTab = NULL;
 		_musicFile[i].idxLen = 0;
 		_musicFile[i].fileSize = 0;
 		_musicFile[i].fileType = 0;
 		_musicFile[i].inUse = false;
 
-		_speechFile[i].file = new Common::File;
 		_speechFile[i].idxTab = NULL;
 		_speechFile[i].idxLen = 0;
 		_speechFile[i].fileSize = 0;
@@ -96,10 +94,13 @@
 	free(_mixBuffer);
 
 	for (int i = 0; i < MAXMUS; i++) {
-		if (_musicFile[i].file->isOpen())
-			_musicFile[i].file->close();
-		if (_speechFile[i].file->isOpen())
-			_speechFile[i].file->close();
+		if (_musicFile[i].file.isOpen())
+			_musicFile[i].file.close();
+		if (_speechFile[i].file.isOpen())
+			_speechFile[i].file.close();
+
+		free(_musicFile[i].idxTab);
+		free(_speechFile[i].idxTab);
 	}
 }
 

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/sword2/sound.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- sound.h	3 Nov 2005 07:28:46 -0000	1.24
+++ sound.h	11 Dec 2005 08:30:47 -0000	1.25
@@ -109,7 +109,7 @@
 };
 
 struct SoundFileHandle {
-	Common::File *file;
+	Common::File file;
 	uint32 *idxTab;
 	uint32 idxLen;
 	uint32 fileSize;





More information about the Scummvm-git-logs mailing list