[Scummvm-cvs-logs] CVS: scummvm/queen graphics.cpp,1.36,1.37 logic.cpp,1.63,1.64 resource.cpp,1.19,1.20 resource.h,1.15,1.16 sound.cpp,1.4,1.5 talk.cpp,1.24,1.25

Joost Peters joostp at users.sourceforge.net
Tue Oct 28 04:44:03 CET 2003


Update of /cvsroot/scummvm/scummvm/queen
In directory sc8-pr-cvs1:/tmp/cvs-serv3685/queen

Modified Files:
	graphics.cpp logic.cpp resource.cpp resource.h sound.cpp 
	talk.cpp 
Log Message:
added loadFileMalloc() method

Index: graphics.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/graphics.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- graphics.cpp	25 Oct 2003 09:12:18 -0000	1.36
+++ graphics.cpp	28 Oct 2003 12:42:35 -0000	1.37
@@ -126,7 +126,7 @@
 void Graphics::bankErase(uint32 bankslot) {
 
 	debug(9, "Graphics::bankErase(%d)", bankslot);
-	free(_banks[bankslot].data);
+	delete[] _banks[bankslot].data;
 	_banks[bankslot].data = 0;	
 }
 
@@ -735,7 +735,7 @@
 	}
 	uint32 size = _resource->fileSize(name);
 	_display->pcxReadBackdrop(pcxbuf, size, room > 114);
-	free(pcxbuf);
+	delete[] pcxbuf;
 
 	if (room >= 90) {
 		_cameraBob = 0;
@@ -751,7 +751,7 @@
 	}
 	uint32 size = _resource->fileSize("panel.pcx");
 	_display->pcxReadPanel(pcxbuf, size);
-	free(pcxbuf);
+	delete[] pcxbuf;
 }
 
 

Index: logic.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/logic.cpp,v
retrieving revision 1.63
retrieving revision 1.64
diff -u -d -r1.63 -r1.64
--- logic.cpp	27 Oct 2003 15:00:25 -0000	1.63
+++ logic.cpp	28 Oct 2003 12:42:35 -0000	1.64
@@ -232,7 +232,7 @@
 }
 
 Logic::~Logic() {
-	free(_jas);
+	delete[] _jas;
 	delete _walk;
 }
 

Index: resource.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- resource.cpp	25 Oct 2003 01:11:14 -0000	1.19
+++ resource.cpp	28 Oct 2003 12:42:35 -0000	1.20
@@ -79,7 +79,7 @@
 	_resourceFile->close();
 	if(_resourceTable != _resourceTablePEM10) 
 		delete[] _resourceTable;
-	free(_JAS2Ptr);
+	delete[] _JAS2Ptr;
 }
 
 int32 Resource::resourceIndex(const char *filename) {
@@ -143,9 +143,18 @@
 
 uint8 *Resource::loadFile(const char *filename, uint32 skipBytes, byte *dstBuf) {
 	uint32 size = fileSize(filename);
-	if (dstBuf == NULL) {
+	if (dstBuf == NULL) 
+		dstBuf = new byte[size];
+	// skip 'skipBytes' bytes (useful for headers)
+	_resourceFile->seek(fileOffset(filename) + skipBytes, SEEK_SET);
+	_resourceFile->read(dstBuf, size - skipBytes);
+	return dstBuf;
+}
+
+uint8 *Resource::loadFileMalloc(const char *filename, uint32 skipBytes, byte *dstBuf) {
+	uint32 size = fileSize(filename);
+	if (dstBuf == NULL)
 		dstBuf = (byte *)malloc(size);
-	}
 	// skip 'skipBytes' bytes (useful for headers)
 	_resourceFile->seek(fileOffset(filename) + skipBytes, SEEK_SET);
 	_resourceFile->read(dstBuf, size - skipBytes);

Index: resource.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/resource.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- resource.h	20 Oct 2003 19:18:02 -0000	1.15
+++ resource.h	28 Oct 2003 12:42:35 -0000	1.16
@@ -61,6 +61,7 @@
 	Resource(const Common::String &datafilePath, const char *datafileName);
 	~Resource(void);
 	uint8 *loadFile(const char *filename, uint32 skipBytes = 0, byte *dstBuf = NULL);
+	uint8 *loadFileMalloc(const char *filename, uint32 skipBytes = 0, byte *dstBuf = NULL);
 	char *getJAS2Line();
 	bool exists(const char *filename);
 	bool isDemo();

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/sound.cpp,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- sound.cpp	25 Oct 2003 01:11:14 -0000	1.4
+++ sound.cpp	28 Oct 2003 12:42:35 -0000	1.5
@@ -80,7 +80,7 @@
 	  _input->delay(10);
 	
 	if (_resource->exists(name)) 
-		playSound(_resource->loadFile(name, SB_HEADER_SIZE), _resource->fileSize(name) - SB_HEADER_SIZE);
+		playSound(_resource->loadFileMalloc(name, SB_HEADER_SIZE), _resource->fileSize(name) - SB_HEADER_SIZE);
 }
 
 #ifdef USE_MAD

Index: talk.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/queen/talk.cpp,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- talk.cpp	25 Oct 2003 01:11:14 -0000	1.24
+++ talk.cpp	28 Oct 2003 12:42:35 -0000	1.25
@@ -78,7 +78,7 @@
 }
 
 Talk::~Talk() {
-	free(_fileData);
+	delete[] _fileData;
 }
 
 





More information about the Scummvm-git-logs mailing list