[Scummvm-cvs-logs] CVS: scummvm/gob cdrom.cpp,1.8,1.9 dataio.cpp,1.14,1.15 draw.cpp,1.21,1.22 draw.h,1.10,1.11 game.cpp,1.35,1.36 game.h,1.9,1.10 global.cpp,1.12,1.13 global.h,1.11,1.12 gob.h,1.18,1.19 goblin.cpp,1.33,1.34 goblin.h,1.11,1.12 init.cpp,1.17,1.18 map.cpp,1.23,1.24 map.h,1.14,1.15 mult.cpp,1.18,1.19 mult.h,1.9,1.10 pack.cpp,1.8,1.9 palanim.cpp,1.15,1.16 scenery.cpp,1.25,1.26 scenery.h,1.10,1.11 sound.cpp,1.16,1.17 sound.h,1.12,1.13 util.cpp,1.21,1.22 util.h,1.8,1.9 video.cpp,1.19,1.20 video.h,1.12,1.13

Eugene Sandulenko sev at users.sourceforge.net
Sat Jan 28 18:28:00 CET 2006


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

Modified Files:
	cdrom.cpp dataio.cpp draw.cpp draw.h game.cpp game.h 
	global.cpp global.h gob.h goblin.cpp goblin.h init.cpp map.cpp 
	map.h mult.cpp mult.h pack.cpp palanim.cpp scenery.cpp 
	scenery.h sound.cpp sound.h util.cpp util.h video.cpp video.h 
Log Message:
Patch #1417631: "gobliiins cleanup". Thanks, wjp.


Index: cdrom.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/cdrom.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- cdrom.cpp	18 Jan 2006 17:39:34 -0000	1.8
+++ cdrom.cpp	29 Jan 2006 02:27:10 -0000	1.9
@@ -86,14 +86,14 @@
 		_vm->_dataio->seekData(handle, pos, SEEK_CUR);
 	}
 
-	_LICbuffer = (byte *)malloc(_numTracks * 22);
+	_LICbuffer = new byte[_numTracks * 22];
 	_vm->_dataio->readData(handle, (char *)_LICbuffer, _numTracks * 22);
 
 	_vm->_dataio->closeData(handle);
 }
 
 void CDROM::freeLICbuffer(void) {
-	free(_LICbuffer);
+	delete[] _LICbuffer;
 	_LICbuffer = 0;
 }
 

Index: dataio.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/dataio.cpp,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- dataio.cpp	18 Jan 2006 17:39:34 -0000	1.14
+++ dataio.cpp	29 Jan 2006 02:27:10 -0000	1.15
@@ -185,7 +185,7 @@
 	char path[128];
 	int16 i;
 	int16 file;
-	struct ChunkDesc *dataDesc;
+	ChunkDesc *dataDesc;
 
 	strcpy(path, src);
 	for (i = 0; path[i] != '.' && path[i] != 0; i++);
@@ -207,9 +207,8 @@
 
 	debug(7, "DataChunks: %d [for %s]", _vm->_global->_numDataChunks[file], path);
 
-	_vm->_global->_dataFiles[file] = dataDesc =
-	    (struct ChunkDesc *)malloc(sizeof(struct ChunkDesc) *
-	    _vm->_global->_numDataChunks[file]);
+	dataDesc = new ChunkDesc[_vm->_global->_numDataChunks[file]];
+	_vm->_global->_dataFiles[file] = dataDesc;
 
 	for (i = 0; i < _vm->_global->_numDataChunks[file]; i++) {
 		file_getHandle(_vm->_global->_dataFileHandles[file])->read(dataDesc[i].chunkName, 13);
@@ -230,7 +229,7 @@
 	int16 file;
 	for (file = MAX_DATA_FILES - 1; file >= 0; file--) {
 		if (_vm->_global->_dataFiles[file] != 0) {
-			free(_vm->_global->_dataFiles[file]);
+			delete[] _vm->_global->_dataFiles[file];
 			_vm->_global->_dataFiles[file] = 0;
 			file_getHandle(_vm->_global->_dataFileHandles[file])->close();
 			return;
@@ -254,13 +253,13 @@
 	if (chunk == -1)
 		return 0;
 
-	unpackBuf = (char *)malloc(realSize);
+	unpackBuf = new char[realSize];
 	if (unpackBuf == 0)
 		return 0;
 
-	packBuf = (char *)malloc(_vm->_global->_packedSize);
+	packBuf = new char[_vm->_global->_packedSize];
 	if (packBuf == 0) {
-		free(unpackBuf);
+		delete[] unpackBuf;
 		return 0;
 	}
 
@@ -274,7 +273,8 @@
 	readChunk(chunk, ptr, sizeLeft);
 	freeChunk(chunk);
 	_vm->_pack->unpackData(packBuf, unpackBuf);
-	free(packBuf);
+
+	delete[] packBuf;
 	return unpackBuf;
 }
 
@@ -346,7 +346,7 @@
 		return data;
 
 	size = getDataSize(path);
-	data = (char *)malloc(size);
+	data = new char[size];
 	if (data == 0)
 		return 0;
 

Index: draw.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/draw.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- draw.cpp	18 Jan 2006 17:39:34 -0000	1.21
+++ draw.cpp	29 Jan 2006 02:27:10 -0000	1.22
@@ -417,7 +417,7 @@
 				    _destSpriteX + _spriteRight - 1,
 				    _destSpriteY + _spriteBottom - 1);
 			}
-			free(dataBuf);
+			delete[] dataBuf;
 			break;
 		}
 		// Load from .TOT resources

Index: draw.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/draw.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- draw.h	18 Jan 2006 17:39:34 -0000	1.10
+++ draw.h	29 Jan 2006 02:27:10 -0000	1.11
@@ -33,13 +33,13 @@
 
 class Draw {
 public:
-	typedef struct FontToSprite {
+	struct FontToSprite {
 		int8 sprite;
 		int8 base;
 		int8 width;
 		int8 height;
 		FontToSprite() : sprite(0), base(0), width(0), height() {}
-	} FontToSprite;
+	};
 
 	int16 _fontIndex;
 	int16 _spriteLeft;

Index: game.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/game.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- game.cpp	18 Jan 2006 17:39:34 -0000	1.35
+++ game.cpp	29 Jan 2006 02:27:10 -0000	1.36
@@ -141,10 +141,11 @@
 
 	debug(7, "off: %ld size: %ld", offset, tableSize);
 	_vm->_dataio->seekData(handle, offset + tableSize, SEEK_SET);
+	// CHECKME: is the below correct?
 	if (isPacked)
-		dataBuf = (char *)malloc(size);
+		dataBuf = new char[size];
 	else
-		dataBuf = (char *)malloc(size);
+		dataBuf = new char[size];
 
 	dataPtr = dataBuf;
 	while (size > 32000) {
@@ -161,9 +162,9 @@
 
 	if (isPacked != 0) {
 		packedBuf = dataBuf;
-		dataBuf = (char *)malloc(READ_LE_UINT32(packedBuf));
+		dataBuf = new char[READ_LE_UINT32(packedBuf)];
 		_vm->_pack->unpackData(packedBuf, dataBuf);
-		free(packedBuf);
+		delete[] packedBuf;
 	}
 
 	return dataBuf;
@@ -229,7 +230,7 @@
 			size++;
 	}
 
-	destPtr = (Collision *)malloc(size * sizeof(Collision));
+	destPtr = new Collision[size];
 	_collStack[_collStackSize] = destPtr;
 	_collStackElemSizes[_collStackSize] = size;
 	_collStackSize++;
@@ -392,7 +393,7 @@
 void Game::loadSound(int16 slot, char *dataPtr) {
 	Snd::SoundDesc *soundDesc;
 
-	soundDesc = (Snd::SoundDesc *)malloc(sizeof(Snd::SoundDesc));
+	soundDesc = new Snd::SoundDesc;
 
 	_soundSamples[slot] = soundDesc;
 
@@ -437,11 +438,11 @@
 		return;
 
 	if (_soundFromExt[slot] == 1) {
-		free(_soundSamples[slot]->data - 6);
+		delete[] (_soundSamples[slot]->data - 6);
 		_soundFromExt[slot] = 0;
 	}
 
-	free(_soundSamples[slot]);
+	delete _soundSamples[slot];
 	_soundSamples[slot] = 0;
 }
 
@@ -1687,8 +1688,10 @@
 	count = FROM_LE_16(count);
 
 	_vm->_dataio->seekData(_extHandle, 0, 0);
-	_extTable = (ExtTable *)malloc(sizeof(ExtTable)
-	    + sizeof(ExtItem) * count);
+	_extTable = new ExtTable;
+	_extTable->items = 0;
+	if (count)
+		_extTable->items = new ExtItem[count];
 
 	_vm->_dataio->readData(_extHandle, (char *)&_extTable->itemsCount, 2);
 	_extTable->itemsCount = FROM_LE_16(_extTable->itemsCount);
@@ -1855,7 +1858,7 @@
 			_vm->_global->_inter_animDataSize = READ_LE_UINT16((char *)_totFileData + 0x38);
 			if (_vm->_global->_inter_variables == 0) {
 				variablesCount = READ_LE_UINT32((char *)_totFileData + 0x2c);
-				_vm->_global->_inter_variables = (char *)malloc(variablesCount * 4);
+				_vm->_global->_inter_variables = new char[variablesCount * 4];
 				for (i = 0; i < variablesCount; i++)
 					WRITE_VAR(i, 0);
 			}
@@ -1877,21 +1880,23 @@
 
 			variablesCount = READ_LE_UINT32((char *)_totFileData + 0x2c);
 			_vm->_draw->blitInvalidated();
-			free(_totFileData);
+			delete[] _totFileData;
 			_totFileData = 0;
 
 			if (needTextFree)
-				free(_totTextData);
+				delete[] _totTextData;
 			_totTextData = 0;
 
 			if (needFreeResTable)
-				free(_totResourceTable);
+				delete[] _totResourceTable;
 			_totResourceTable = 0;
 
-			free(_imFileData);
+			delete[] _imFileData;
 			_imFileData = 0;
 
-			free(_extTable);
+			if (_extTable)
+				delete[] _extTable->items;
+			delete _extTable;
 			_extTable = 0;
 
 			if (_extHandle >= 0)
@@ -1931,11 +1936,11 @@
 }
 
 void Game::start(void) {
-	_collisionAreas = (Collision *)malloc(250 * sizeof(Collision));
+	_collisionAreas = new Collision[250];
 	prepareStart();
 	playTot(0);
 
-	free(_collisionAreas);
+	delete[] _collisionAreas;
 
 	_vm->_video->freeSurfDesc(_vm->_draw->_cursorSprites);
 	_vm->_video->freeSurfDesc(_vm->_draw->_cursorBack);

Index: game.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/game.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- game.h	18 Jan 2006 17:39:34 -0000	1.9
+++ game.h	29 Jan 2006 02:27:10 -0000	1.10
@@ -31,7 +31,7 @@
 
 #pragma START_PACK_STRUCTS
 #define szGame_TotResItem (4 + 2 + 2 + 2)
-	typedef struct Collision {
+	struct Collision {
 		int16 id;
 		int16 left;
 		int16 top;
@@ -41,56 +41,56 @@
 		int16 key;
 		int16 funcEnter;
 		int16 funcLeave;
-	} GCC_PACK Collision;
+	} GCC_PACK;
 
-	typedef struct TotResItem {
+	struct TotResItem {
 		int32 offset;	// if > 0, then offset from end of resource table.
 						// If < 0, then -offset-1 is index in .IM file table
 		int16 size;
 		int16 width;
 		int16 height;
-	} GCC_PACK TotResItem;
+	} GCC_PACK;
 
 #define szGame_TotResTable (2 + 1)
-	typedef struct TotResTable {
+	struct TotResTable {
 		int16 itemsCount;
 		byte unknown;
 		TotResItem items[1];
-	} GCC_PACK TotResTable;
+	} GCC_PACK;
 
 #define szGame_ExtItem (4 + 2 + 2 + 2)
-	typedef struct ExtItem {
+	struct ExtItem {
 		int32 offset;		// offset from the table end
 		uint16 size;
 		int16 width;		// width&0x7fff - width, width&0x8000 - pack flag
 		int16 height;		// not zero
-	} GCC_PACK ExtItem;
+	} GCC_PACK;
 
 #define szGame_ExtTable (2 + 1)
-	typedef struct ExtTable {
+	struct ExtTable {
 		int16 itemsCount;
 		byte unknown;
-		ExtItem items[1];
-	} GCC_PACK ExtTable;
+		ExtItem* items;
+	} GCC_PACK;
 
 #define szGame_TotTextItem (2 + 2)
-	typedef struct TotTextItem {
+	struct TotTextItem {
 		int16 offset;
 		int16 size;
-	} GCC_PACK TotTextItem;
+	} GCC_PACK;
 
 #define szGame_TotTextTable (2)
-	typedef struct TotTextTable {
+	struct TotTextTable {
 		int16 itemsCount;
 		TotTextItem items[1];
-	} GCC_PACK TotTextTable;
+	} GCC_PACK;
 
-	typedef struct InputDesc {
+	struct InputDesc {
 		int16 fontIndex;
 		int16 backColor;
 		int16 frontColor;
 		char *ptr;
-	} GCC_PACK InputDesc;
+	} GCC_PACK;
 #pragma END_PACK_STRUCTS
 
 	TotResTable *_totResourceTable;

Index: global.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/global.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- global.cpp	18 Jan 2006 17:39:34 -0000	1.12
+++ global.cpp	29 Jan 2006 02:27:10 -0000	1.13
@@ -88,8 +88,6 @@
 
 	_oldMode = 3;
 	_dontSetPalette = 0;
-	_curPrimaryDesc = 0;
-	_allocatedPrimary = 0;
 	_pPrimarySurfDesc = 0;
 
 	_pPaletteDesc = 0;
@@ -146,8 +144,6 @@
 
 	_inter_mouseX = 0;
 	_inter_mouseY = 0;
-
-	_tmpPalBuffer = 0;
 }
 
 } // End of namespace Gob

Index: global.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/global.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- global.h	18 Jan 2006 17:39:34 -0000	1.11
+++ global.h	29 Jan 2006 02:27:10 -0000	1.12
@@ -134,9 +134,7 @@
 
 	int16 _setAllPalette;
 
-	Video::SurfaceDesc *_curPrimaryDesc;
-	Video::SurfaceDesc *_allocatedPrimary;
-	Video::SurfaceDesc_t _primarySurfDesc;
+	Video::SurfaceDesc _primarySurfDesc;
 	Video::SurfaceDesc *_pPrimarySurfDesc;
 
 	int16 _oldMode;
@@ -163,8 +161,6 @@
 	int16 _inter_mouseX;
 	int16 _inter_mouseY;
 
-	char *_tmpPalBuffer;
-
 	Global(GobEngine *vm);
 
 protected:

Index: gob.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/gob.h,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- gob.h	21 Jan 2006 13:01:18 -0000	1.18
+++ gob.h	29 Jan 2006 02:27:10 -0000	1.19
@@ -73,7 +73,7 @@
 	GF_MAC = 1 << 5
 };
 
-typedef struct GobGameSettings {
+struct GobGameSettings {
 	const char *gameid;
 	const char *description;
 	uint32 features;
@@ -82,7 +82,7 @@
 		GameSettings dummy = { gameid, description, features };
 		return dummy;
 	}
-} GobGameSettings;
+};
 
 class GobEngine : public Engine {
 	void errorString(const char *buf_input, char *buf_output);

Index: goblin.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/goblin.cpp,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- goblin.cpp	27 Jan 2006 23:19:18 -0000	1.33
+++ goblin.cpp	29 Jan 2006 02:27:10 -0000	1.34
@@ -177,7 +177,7 @@
 }
 
 void Goblin::initList(void) {
-	_objList = (Util::List *) malloc(sizeof(Util::List));
+	_objList = new Util::List;
 	_objList->pHead = 0;
 	_objList->pTail = 0;
 }
@@ -1848,7 +1848,7 @@
 		}
 
 		delete[] _goblins[i]->stateMach;
-		free(_goblins[i]);
+		delete _goblins[i];
 		_goblins[i] = 0;
 	}
 
@@ -1866,7 +1866,7 @@
 		}
 
 		delete[] _objects[i]->stateMach;
-		free(_objects[i]);
+		delete _objects[i];
 		_objects[i] = 0;
 	}
 }

Index: goblin.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/goblin.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- goblin.h	27 Jan 2006 23:19:18 -0000	1.11
+++ goblin.h	29 Jan 2006 02:27:10 -0000	1.12
@@ -34,7 +34,7 @@
 class Goblin {
 public:
 #pragma START_PACK_STRUCTS
-	typedef struct Gob_State {
+	struct Gob_State {
 		int16 animation;// +0h
 		int16 layer;	// +2h
 		int16 unk0;		// +4h
@@ -43,13 +43,13 @@
 		int16 freq;		// +Ah, high/low byte * 100 - frequency
 		int16 repCount;	// +Ch high/low byte - repeat count
 		int16 sndFrame;		// +Eh
-	} GCC_PACK Gob_State;
+	} GCC_PACK;
 
 	typedef Gob_State *Gob_PState;
 
 	typedef Gob_PState Gob_StateLine[6];
 
-	typedef struct Gob_Object {
+	struct Gob_Object {
 		int16 animation;	// +0h
 		int16 state;		// +2h
 		int16 stateColumn;	// +4h
@@ -82,12 +82,12 @@
 		char multObjIndex;	// +37h, from which play mult animations
 		char unk14;			// +38h
 		char visible;		// +39h
-	} GCC_PACK Gob_Object;
+	} GCC_PACK;
 
-	typedef struct Gob_Pos {
+	struct Gob_Pos {
 		char x;
 		char y;
-	} GCC_PACK Gob_Pos;
+	} GCC_PACK;
 #pragma END_PACK_STRUCTS
 
 	Util::List *_objList;

Index: init.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/init.cpp,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- init.cpp	18 Jan 2006 17:39:34 -0000	1.17
+++ init.cpp	29 Jan 2006 02:27:10 -0000	1.18
@@ -104,13 +104,9 @@
 		_vm->_gtimer->disableTimer();
 
 	_vm->_video->freeDriver();
-	if (_vm->_global->_curPrimaryDesc != 0) {
-		_vm->_video->freeSurfDesc(_vm->_global->_curPrimaryDesc);
-		_vm->_video->freeSurfDesc(_vm->_global->_allocatedPrimary);
-		_vm->_global->_allocatedPrimary = 0;
-		_vm->_global->_curPrimaryDesc = 0;
-	}
+	_vm->_video->freeSurfDesc(_vm->_global->_pPrimarySurfDesc);
 	_vm->_global->_pPrimarySurfDesc = 0;
+
 	if (_vm->_snd->_cleanupFunc != 0 && _vm->_snd->_playingSound != 0) {
 		(*_vm->_snd->_cleanupFunc) (0);
 		_vm->_snd->_cleanupFunc = 0;
@@ -172,7 +168,7 @@
 	_vm->_game->_totFileData = 0;
 	_vm->_game->_totResourceTable = 0;
 	_vm->_global->_inter_variables = 0;
-	_palDesc = (Video::PalDesc *)malloc(12);
+	_palDesc = new Video::PalDesc;
 
 	if (_vm->_global->_videoMode != 0x13)
 		error("initGame: Only 0x13 video mode is supported!");
@@ -224,8 +220,7 @@
 			if (infPtr == infEnd)
 				break;
 		}
-
-		free(infBuf);
+		delete[] infBuf;
 	}
 
 	if (totName != 0) {
@@ -244,7 +239,7 @@
 		varsCount = FROM_LE_32(varsCount);
 		_vm->_dataio->closeData(handle);
 
-		_vm->_global->_inter_variables = (char *)malloc(varsCount * 4);
+		_vm->_global->_inter_variables = new char[varsCount * 4];
 		memset(_vm->_global->_inter_variables, 0, varsCount * 4);
 
 		strcpy(_vm->_game->_curTotFile, buffer);
@@ -256,10 +251,10 @@
 		_vm->_cdrom->stopPlaying();
 		_vm->_cdrom->freeLICbuffer();
 
-		free(_vm->_global->_inter_variables);
-		free(_vm->_game->_totFileData);
-		free(_vm->_game->_totTextData);
-		free(_vm->_game->_totResourceTable);
+		delete[] _vm->_global->_inter_variables;
+		delete[] _vm->_game->_totFileData;
+		delete[] _vm->_game->_totTextData;
+		delete[] _vm->_game->_totResourceTable;
 	}
 
 	for (i = 0; i < 4; i++) {
@@ -267,7 +262,7 @@
 			_vm->_util->freeFont(_vm->_draw->_fonts[i]);
 	}
 
-	free(_palDesc);
+	delete _palDesc;
 	_vm->_dataio->closeDataFile();
 	_vm->_video->initPrimary(-1);
 	cleanup();

Index: map.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/map.cpp,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- map.cpp	27 Jan 2006 23:19:18 -0000	1.23
+++ map.cpp	29 Jan 2006 02:27:10 -0000	1.24
@@ -512,7 +512,7 @@
 
 	_vm->_goblin->_gobsCount = loadFromAvo_LE_UINT16();
 	for (i = 0; i < _vm->_goblin->_gobsCount; i++) {
-		_vm->_goblin->_goblins[i] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object));
+		_vm->_goblin->_goblins[i] = new Goblin::Gob_Object;
 
 		_vm->_goblin->_goblins[i]->xPos = READ_LE_UINT16(savedPtr2);
 		savedPtr2 += 2;
@@ -620,8 +620,7 @@
 
 	_vm->_goblin->_objCount = loadFromAvo_LE_UINT16();
 	for (i = 0; i < _vm->_goblin->_objCount; i++) {
-		_vm->_goblin->_objects[i] =
-		    (Goblin::Gob_Object *) malloc(sizeof(Goblin::Gob_Object));
+		_vm->_goblin->_objects[i] = new Goblin::Gob_Object;
 
 		_vm->_goblin->_objects[i]->xPos = READ_LE_UINT16(savedPtr3);
 		savedPtr3 += 2;
@@ -681,7 +680,7 @@
 		delete[] tempstatedata;
 	}
 
-	_vm->_goblin->_objects[10] = (Goblin::Gob_Object *)malloc(sizeof(Goblin::Gob_Object));
+	_vm->_goblin->_objects[10] = new Goblin::Gob_Object;
 	memset(_vm->_goblin->_objects[10], 0, sizeof(Goblin::Gob_Object));
 
 	_vm->_goblin->_objects[10]->stateMach = new Goblin::Gob_StateLine[40];
@@ -728,7 +727,7 @@
 		strcpy(sndNames[i], buf);
 	}
 
-	free(dataBuf);
+	delete[] dataBuf;
 
 	_vm->_goblin->_soundData[14] = _vm->_snd->loadSoundData("diamant1.snd");
 

Index: map.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/map.h,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- map.h	18 Jan 2006 17:39:34 -0000	1.14
+++ map.h	29 Jan 2006 02:27:10 -0000	1.15
@@ -45,18 +45,18 @@
 
 #pragma START_PACK_STRUCTS
 
-	typedef struct Point {
+	struct Point {
 		int16 x;
 		int16 y;
-	} GCC_PACK Point;
+	} GCC_PACK;
 
 #define szMap_ItemPos 3
 
-	typedef struct ItemPos {
+	struct ItemPos {
 		int8 x;
 		int8 y;
 		int8 orient;		// ??
-	} GCC_PACK ItemPos;
+	} GCC_PACK;
 
 #pragma END_PACK_STRUCTS
 

Index: mult.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/mult.cpp,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- mult.cpp	18 Jan 2006 17:39:34 -0000	1.18
+++ mult.cpp	29 Jan 2006 02:27:10 -0000	1.19
@@ -437,8 +437,8 @@
 	animDataVar = _vm->_parse->parseVarIndex();
 
 	if (_objects == 0) {
-		_renderData = (int16 *)malloc(sizeof(int16) * _objCount * 9);
-		_objects = (Mult_Object *)malloc(sizeof(Mult_Object) * _objCount);
+		_renderData = new int16[_objCount * 9];
+		_objects = new Mult_Object[_objCount];
 
 		for (i = 0; i < _objCount; i++) {
 			_objects[i].pPosX = (int32 *)(_vm->_global->_inter_variables + i * 4 + (posXVar / 4) * 4);
@@ -487,8 +487,8 @@
 	if (_vm->_anim->_animSurf != 0)
 		_vm->_video->freeSurfDesc(_vm->_anim->_animSurf);
 
-	free(_objects);
-	free(_renderData);
+	delete[] _objects;
+	delete[] _renderData;
 
 	_objects = 0;
 	_renderData = 0;
@@ -860,13 +860,13 @@
 			_vm->_anim->_areaHeight = 200;
 			_objCount = 4;
 
-			_objects = (Mult_Object *)malloc(sizeof(Mult_Object) * _objCount);
-			_renderData = (int16 *)malloc(sizeof(int16) * 9 * _objCount);
+			_objects = new Mult_Object[_objCount];
+			_renderData = new int16[9 * _objCount];
 
-			_animArrayX = (int32 *)malloc(sizeof(int32) * _objCount);
-			_animArrayY = (int32 *)malloc(sizeof(int32) * _objCount);
+			_animArrayX = new int32[_objCount];
+			_animArrayY = new int32[_objCount];
 
-			_animArrayData = (Mult_AnimData *)malloc(sizeof(Mult_AnimData) * _objCount);
+			_animArrayData = new Mult_AnimData[_objCount];
 
 			for (_counter = 0; _counter < _objCount; _counter++) {
 				multObj = &_objects[_counter];
@@ -940,19 +940,19 @@
 
 	if (stopNoClear == 0) {
 		if (_animDataAllocated) {
-			free(_objects);
+			delete[] _objects;
 			_objects = 0;
 
-			free(_renderData);
+			delete[] _renderData;
 			_renderData = 0;
 
-			free(_animArrayX);
+			delete[] _animArrayX;
 			_animArrayX = 0;
 
-			free(_animArrayY);
+			delete[] _animArrayY;
 			_animArrayY = 0;
 
-			free(_animArrayData);
+			delete[] _animArrayData;
 			_animArrayData = 0;
 
 			if (_vm->_anim->_animSurf)
@@ -1020,8 +1020,7 @@
 	_staticKeysCount = READ_LE_UINT16(_dataPtr);
 	_dataPtr += 2;
 
-	_staticKeys = (Mult_StaticKey *)malloc(sizeof(Mult_StaticKey) *
-	    _staticKeysCount);
+	_staticKeys = new Mult_StaticKey[_staticKeysCount];
 	for (i = 0; i < _staticKeysCount; i++, _dataPtr += 4) {
 		_staticKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
 		_staticKeys[i].layer = (int16)READ_LE_UINT16(_dataPtr + 2);
@@ -1031,7 +1030,7 @@
 		_animKeysCount[j] = READ_LE_UINT16(_dataPtr);
 		_dataPtr += 2;
 
-		_animKeys[j] = (Mult_AnimKey *) malloc(sizeof(Mult_AnimKey) * _animKeysCount[j]);
+		_animKeys[j] = new Mult_AnimKey[_animKeysCount[j]];
 		for (i = 0; i < _animKeysCount[j]; i++, _dataPtr += 10) {
 			_animKeys[j][i].frame = (int16)READ_LE_UINT16(_dataPtr);
 			_animKeys[j][i].layer = (int16)READ_LE_UINT16(_dataPtr + 2);
@@ -1052,7 +1051,7 @@
 
 	_palFadeKeysCount = READ_LE_UINT16(_dataPtr);
 	_dataPtr += 2;
-	_palFadeKeys = (Mult_PalFadeKey *)malloc(sizeof(Mult_PalFadeKey) * _palFadeKeysCount);
+	_palFadeKeys = new Mult_PalFadeKey[_palFadeKeysCount];
 
 	for (i = 0; i < _palFadeKeysCount; i++, _dataPtr += 7) {
 		_palFadeKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
@@ -1064,7 +1063,7 @@
 	_palKeysCount = READ_LE_UINT16(_dataPtr);
 	_dataPtr += 2;
 
-	_palKeys = (Mult_PalKey *)malloc(sizeof(Mult_PalKey) * _palKeysCount);
+	_palKeys = new Mult_PalKey[_palKeysCount];
 	for (i = 0; i < _palKeysCount; i++, _dataPtr += 80) {
 		_palKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
 		_palKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
@@ -1079,7 +1078,7 @@
 
 	_textKeysCount = READ_LE_UINT16(_dataPtr);
 	_dataPtr += 2;
-	_textKeys = (Mult_TextKey *) malloc(sizeof(Mult_TextKey) * _textKeysCount);
+	_textKeys = new Mult_TextKey[_textKeysCount];
 
 	for (i = 0; i < _textKeysCount; i++, _dataPtr += 28) {
 		_textKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
@@ -1094,7 +1093,7 @@
 	_sndKeysCount = READ_LE_UINT16(_dataPtr);
 	_dataPtr += 2;
 
-	_sndKeys = (Mult_SndKey *)malloc(sizeof(Mult_SndKey) * _sndKeysCount);
+	_sndKeys = new Mult_SndKey[_sndKeysCount];
 	for (i = 0; i < _sndKeysCount; i++) {
 		_sndKeys[i].frame = (int16)READ_LE_UINT16(_dataPtr);
 		_sndKeys[i].cmd = (int16)READ_LE_UINT16(_dataPtr + 2);
@@ -1149,7 +1148,7 @@
 	staticCount = _dataPtr[0];
 	animCount = _dataPtr[1];
 
-	free(_dataPtr);
+	delete[] _dataPtr;
 
 	staticCount++;
 	animCount++;
@@ -1164,37 +1163,37 @@
 			_vm->_scenery->freeAnim(_animIndices[i]);
 	}
 
-	free(_staticKeys);
+	delete[] _staticKeys;
 
 	for (i = 0; i < 4; i++)
-		free(_animKeys[i]);
+		delete[] _animKeys[i];
 
-	free(_palFadeKeys);
-	free(_palKeys);
-	free(_textKeys);
+	delete[] _palFadeKeys;
+	delete[] _palKeys;
+	delete[] _textKeys;
 
 	for (i = 0; i < _sndSlotsCount; i++) {
 		_vm->_game->freeSoundSlot(19 - i);
 	}
 
-	free(_sndKeys);
+	delete[] _sndKeys;
 
 	_multData = 0;
 
 	if (_animDataAllocated != 0) {
-		free(_objects);
+		delete[] _objects;
 		_objects = 0;
 
-		free(_renderData);
+		delete[] _renderData;
 		_renderData = 0;
 
-		free(_animArrayX);
+		delete[] _animArrayX;
 		_animArrayX = 0;
 
-		free(_animArrayY);
+		delete[] _animArrayY;
 		_animArrayY = 0;
 
-		free(_animArrayData);
+		delete[] _animArrayData;
 		_animArrayData = 0;
 
 		if (_vm->_anim->_animSurf)

Index: mult.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/mult.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- mult.h	18 Jan 2006 17:39:34 -0000	1.9
+++ mult.h	29 Jan 2006 02:27:10 -0000	1.10
@@ -29,7 +29,7 @@
 class Mult {
 public:
 #pragma START_PACK_STRUCTS
-	typedef struct Mult_AnimData {
+	struct Mult_AnimData {
 		int8 animation;
 		int8 layer;
 		int8 frame;
@@ -43,9 +43,9 @@
 		int8 newAnimation;
 		byte intersected;
 		int8 newCycle;
-	} GCC_PACK Mult_AnimData;
+	} GCC_PACK;
 
-	typedef struct Mult_Object {
+	struct Mult_Object {
 		int32 *pPosX;
 		int32 *pPosY;
 		Mult_AnimData *pAnimData;
@@ -54,47 +54,46 @@
 		int16 lastRight;
 		int16 lastTop;
 		int16 lastBottom;
-	} Mult_Object;
+	};
 
-	// Mult
-	typedef struct Mult_StaticKey {
+	struct Mult_StaticKey {
 		int16 frame;
 		int16 layer;
-	} GCC_PACK Mult_StaticKey;
+	} GCC_PACK;
 
-	typedef struct Mult_AnimKey {
+	struct Mult_AnimKey {
 		int16 frame;
 		int16 layer;
 		int16 posX;
 		int16 posY;
 		int16 order;
-	} GCC_PACK Mult_AnimKey;
+	} GCC_PACK;
 
-	typedef struct Mult_TextKey {
+	struct Mult_TextKey {
 		int16 frame;
 		int16 cmd;
 		int16 unknown0[9];
 		int16 index;
 		int16 unknown1[2];
-	} GCC_PACK Mult_TextKey;
+	} GCC_PACK;
 
-	typedef struct Mult_PalKey {
+	struct Mult_PalKey {
 		int16 frame;
 		int16 cmd;
 		int16 rates[4];
 		int16 unknown0;
 		int16 unknown1;
 		int8 subst[16][4];
-	} GCC_PACK Mult_PalKey;
+	} GCC_PACK;
 
-	typedef struct Mult_PalFadeKey {
+	struct Mult_PalFadeKey {
 		int16 frame;
 		int16 fade;
 		int16 palIndex;
 		int8 flag;
-	} GCC_PACK Mult_PalFadeKey;
+	} GCC_PACK;
 
-	typedef struct Mult_SndKey {
+	struct Mult_SndKey {
 		int16 frame;
 		int16 cmd;
 		int16 freq;
@@ -102,7 +101,7 @@
 		int16 repCount;
 		int16 resId;
 		int16 soundIndex;
-	} GCC_PACK Mult_SndKey;
+	} GCC_PACK;
 #pragma END_PACK_STRUCTS
 
 	// Globals

Index: pack.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/pack.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- pack.cpp	18 Jan 2006 17:39:34 -0000	1.8
+++ pack.cpp	29 Jan 2006 02:27:10 -0000	1.9
@@ -40,7 +40,7 @@
 	realSize = READ_LE_UINT32(sourceBuf);
 	counter = READ_LE_UINT32(sourceBuf);
 
-	tmpBuf = (byte *)malloc(4114);
+	tmpBuf = new byte[4114];
 
 	/*
 	 * Can use assembler unpacker for small blocks - for speed.
@@ -91,7 +91,7 @@
 				*dest++ = tmpBuf[(off + i) % 4096];
 				counter--;
 				if (counter == 0) {
-					free(tmpBuf);
+					delete[] tmpBuf;
 					return realSize;
 				}
 				tmpBuf[tmpIndex] = tmpBuf[(off + i) % 4096];
@@ -100,7 +100,7 @@
 			}
 		}
 	}
-	free(tmpBuf);
+	delete[] tmpBuf;
 	return realSize;
 }
 

Index: palanim.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/palanim.cpp,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- palanim.cpp	18 Jan 2006 17:39:34 -0000	1.15
+++ palanim.cpp	29 Jan 2006 02:27:10 -0000	1.16
@@ -186,8 +186,7 @@
 
 	if (allColors == 0) {
 		do {
-			if (_vm->_global->_tmpPalBuffer == 0)
-				_vm->_video->waitRetrace(_vm->_global->_videoMode);
+			_vm->_video->waitRetrace(_vm->_global->_videoMode);
 
 			stop = fadeStep(0);
 
@@ -222,9 +221,6 @@
 		else
 			_vm->_util->clearPalette();
 	}
-
-	free(_vm->_global->_tmpPalBuffer);
-	_vm->_global->_tmpPalBuffer = 0;
 }
 
 }				// End of namespace Gob

Index: scenery.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/scenery.cpp,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- scenery.cpp	18 Jan 2006 17:39:34 -0000	1.25
+++ scenery.cpp	29 Jan 2006 02:27:10 -0000	1.26
@@ -116,9 +116,9 @@
 	ptr->layersCount = (int16)READ_LE_UINT16(dataPtr);
 	dataPtr += 2;
 
-	ptr->layers = (StaticLayer **)malloc(sizeof(StaticLayer *) * ptr->layersCount);
-	ptr->pieces = (PieceDesc **)malloc(sizeof(PieceDesc *) * picsCount);
-	ptr->piecesFromExt = (int8 *)malloc(picsCount);
+	ptr->layers = new StaticLayer*[ptr->layersCount];
+	ptr->pieces = new PieceDesc*[picsCount];
+	ptr->piecesFromExt = new int8[picsCount];
 
 	for (i = 0; i < ptr->layersCount; i++) {
 		offset = (int16)READ_LE_UINT16(&((int16 *)dataPtr)[i]);
@@ -196,7 +196,7 @@
 
 	for (i = 0; i < _staticPictCount[index]; i++) {
 		if (_statics[index].piecesFromExt[i] == 1)
-			free(_statics[index].pieces[i]);
+			delete[] _statics[index].pieces[i];
 
 		spr = _staticPictToSprite[index * 7 + i];
 		_spriteRefs[spr]--;
@@ -207,11 +207,11 @@
 		}
 	}
 
-	free(_statics[index].layers);
-	free(_statics[index].pieces);
-	free(_statics[index].piecesFromExt);
+	delete[] _statics[index].layers;
+	delete[] _statics[index].pieces;
+	delete[] _statics[index].piecesFromExt;
 	if (_staticFromExt[index] == 1)
-		free(_statics[index].dataPtr);
+		delete[] _statics[index].dataPtr;
 
 	_staticFromExt[index] = 0;
 	_staticPictCount[index] = -1;
@@ -433,13 +433,9 @@
 	ptr->layersCount = READ_LE_UINT16(dataPtr);
 	dataPtr += 2;
 
-	ptr->layers =
-	    (AnimLayer **) malloc(sizeof(AnimLayer *) *
-	    ptr->layersCount);
-	ptr->pieces =
-	    (PieceDesc **) malloc(sizeof(PieceDesc *) *
-	    picsCount);
-	ptr->piecesFromExt = (int8 *) malloc(picsCount);
+	ptr->layers = new AnimLayer*[ptr->layersCount];
+	ptr->pieces = new PieceDesc*[picsCount];
+	ptr->piecesFromExt = new int8[picsCount];
 
 	for (i = 0; i < ptr->layersCount; i++) {
 		offset = (int16)READ_LE_UINT16(&((int16 *)dataPtr)[i]);
@@ -718,7 +714,7 @@
 
 	for (i = 0; i < _animPictCount[animation]; i++) {
 		if (_animations[animation].piecesFromExt[i] == 1)
-			free(_animations[animation].pieces[i]);
+			delete[] _animations[animation].pieces[i];
 
 		spr = _animPictToSprite[animation * 7 + i];
 		_spriteRefs[spr]--;
@@ -730,11 +726,11 @@
 		}
 	}
 
-	free(_animations[animation].layers);
-	free(_animations[animation].pieces);
-	free(_animations[animation].piecesFromExt);
+	delete[] _animations[animation].layers;
+	delete[] _animations[animation].pieces;
+	delete[] _animations[animation].piecesFromExt;
 	if (_animFromExt[animation] == 1)
-		free(_animations[animation].dataPtr);
+		delete[] _animations[animation].dataPtr;
 
 	_animFromExt[animation] = 0;
 	_animPictCount[animation] = 0;

Index: scenery.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/scenery.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- scenery.h	18 Jan 2006 17:39:34 -0000	1.10
+++ scenery.h	29 Jan 2006 02:27:10 -0000	1.11
@@ -27,39 +27,39 @@
 class Scenery {
 public:
 #pragma START_PACK_STRUCTS
-	typedef struct PieceDesc {
+	struct PieceDesc {
 		int16 left;		//NOTE:
 		int16 right;		//These are stored in Little Endian format
 		int16 top;		//And should be converted by client code when accessed
 		int16 bottom;		//i.e. use FROM_LE_16()
-	} GCC_PACK PieceDesc;
+	} GCC_PACK;
 
-	typedef struct StaticPlane {
+	struct StaticPlane {
 		int8 pictIndex;
 		int8 pieceIndex;
 		int8 drawOrder;
 		int16 destX;
 		int16 destY;
 		int8 transp;
-	} GCC_PACK StaticPlane;
+	} GCC_PACK;
 
-	typedef struct StaticLayer {
+	struct StaticLayer {
 		int16 backResId;
 		int16 planeCount;
 		StaticPlane planes[1];
-	} GCC_PACK StaticLayer;
+	} GCC_PACK;
 
 	// Animations
 
-	typedef struct AnimFramePiece {
+	struct AnimFramePiece {
 		byte pictIndex;
 		byte pieceIndex;
 		int8 destX;
 		int8 destY;
 		int8 notFinal;
-	} GCC_PACK AnimFramePiece;
+	} GCC_PACK;
 
-	typedef struct AnimLayer {
+	struct AnimLayer {
 		int16 unknown0;
 		int16 posX;
 		int16 posY;
@@ -68,10 +68,10 @@
 		int8 transp;
 		int16 framesCount;
 		AnimFramePiece frames[1];
-	} GCC_PACK AnimLayer;
+	} GCC_PACK;
 #pragma END_PACK_STRUCTS
 
-	typedef struct Static {
+	struct Static {
 		int16 layersCount;
 		StaticLayer **layers;
 		PieceDesc **pieces;
@@ -79,7 +79,7 @@
 		char *dataPtr;
 		Static() : layersCount(0), layers(0), pieces(0),
 				   piecesFromExt(0), dataPtr(0) {}
-	} Static;
+	};
 
 	struct Animation {
 		int16 layersCount;

Index: sound.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/sound.cpp,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- sound.cpp	18 Jan 2006 17:39:34 -0000	1.16
+++ sound.cpp	29 Jan 2006 02:27:10 -0000	1.17
@@ -118,11 +118,9 @@
 
 Snd::SoundDesc *Snd::loadSoundData(const char *path) {
 	Snd::SoundDesc *sndDesc;
-	int32 size;
 
-	size = _vm->_dataio->getDataSize(path);
-	sndDesc = (Snd::SoundDesc *)malloc(size);
-	sndDesc->size = size;
+	sndDesc = new Snd::SoundDesc;
+	sndDesc->size = _vm->_dataio->getDataSize(path);
 	sndDesc->data = _vm->_dataio->getData(path);
 
 	return sndDesc;
@@ -136,8 +134,8 @@
 			_loopingSounds[i] = NULL;
 	}
 
-	free(sndDesc->data);
-	free(sndDesc);
+	delete[] sndDesc->data;
+	delete sndDesc;
 }
 
 }                               // End of namespace Gob

Index: sound.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/sound.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- sound.h	18 Jan 2006 17:39:34 -0000	1.12
+++ sound.h	29 Jan 2006 02:27:10 -0000	1.13
@@ -28,7 +28,7 @@
 
 class Snd {
 public:
-	typedef struct SoundDesc {
+	struct SoundDesc {
 		Audio::SoundHandle handle;
 		char *data;
 		int32 size;
@@ -39,7 +39,7 @@
 		int16 flag;
 		SoundDesc() : data(0), size(0), repCount(0), timerTicks(0),
 					  inClocks(0), frequency(0), flag(0) {}
-	} SoundDesc;
+	};
 
 	typedef void (*CleanupFuncPtr) (int16);
 

Index: util.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/util.cpp,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- util.cpp	18 Jan 2006 17:39:34 -0000	1.21
+++ util.cpp	29 Jan 2006 02:27:10 -0000	1.22
@@ -271,7 +271,7 @@
 }
 
 Video::FontDesc *Util::loadFont(const char *path) {
-	Video::FontDesc *fontDesc = (Video::FontDesc *) malloc(sizeof(Video::FontDesc));
+	Video::FontDesc *fontDesc = new Video::FontDesc;
 	char *data;
 
 	if (fontDesc == 0)
@@ -279,7 +279,7 @@
 
 	data = _vm->_dataio->getData(path);
 	if (data == 0) {
-		free(fontDesc);
+		delete fontDesc;
 		return 0;
 	}
 
@@ -303,8 +303,8 @@
 }
 
 void Util::freeFont(Video::FontDesc * fontDesc) {
-	free(fontDesc->dataPtr - 4);
-	free(fontDesc);
+	delete[] (fontDesc->dataPtr - 4);
+	delete fontDesc;
 }
 
 void Util::clearPalette(void) {
@@ -390,7 +390,7 @@
 void Util::listInsertFront(List * list, void *data) {
 	ListNode *node;
 
-	node = (ListNode *) malloc(sizeof(ListNode));
+	node = new ListNode;
 	if (list->pHead != 0) {
 		node->pData = data;
 		node->pNext = list->pHead;
@@ -415,8 +415,7 @@
 			warning("listInsertBack: Broken list!");
 		}
 
-		node =
-		    (ListNode *) malloc(sizeof(ListNode));
+		node = new ListNode;
 		node->pData = data;
 		node->pPrev = list->pTail;
 		node->pNext = 0;
@@ -429,12 +428,12 @@
 
 void Util::listDropFront(List * list) {
 	if (list->pHead->pNext == 0) {
-		free((list->pHead));
+		delete list->pHead;
 		list->pHead = 0;
 		list->pTail = 0;
 	} else {
 		list->pHead = list->pHead->pNext;
-		free((list->pHead->pPrev));
+		delete list->pHead->pPrev;
 		list->pHead->pPrev = 0;
 	}
 }
@@ -444,7 +443,7 @@
 		listDropFront(list);
 	}
 
-	free(list);
+	delete list;
 }
 
 const char Util::trStr1[] =

Index: util.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/util.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- util.h	18 Jan 2006 17:39:34 -0000	1.8
+++ util.h	29 Jan 2006 02:27:10 -0000	1.9
@@ -31,18 +31,18 @@
 class Util {
 public:
 	struct ListNode;
-	typedef struct ListNode {
+	struct ListNode {
 		void *pData;
 		struct ListNode *pNext;
 		struct ListNode *pPrev;
 		ListNode() : pData(0), pNext(0), pPrev(0) {}
-	} ListNode;
+	};
 
-	typedef struct List {
+	struct List {
 		ListNode *pHead;
 		ListNode *pTail;
 		List() : pHead(0), pTail(0) {}
-	} List;
+	};
 
 	void initInput(void);
 	void processInput(void);

Index: video.cpp
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/video.cpp,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- video.cpp	18 Jan 2006 17:39:34 -0000	1.19
+++ video.cpp	29 Jan 2006 02:27:10 -0000	1.20
@@ -85,7 +85,7 @@
 
 Video::SurfaceDesc *Video::initSurfDesc(int16 vidMode, int16 width, int16 height, int16 flags) {
 	int8 flagsAnd2;
-	byte *vidMem;
+	byte *vidMem = 0;
 	int32 sprSize;
 	int16 someFlags = 1;
 	SurfaceDesc *descPtr;
@@ -108,27 +108,31 @@
 		flagsAnd2 = 0;
 
 	if (flags & PRIMARY_SURFACE) {
-		vidMem = 0;
 		_vm->_global->_primaryWidth = width;
 		_vm->_global->_mouseMaxCol = width;
 		_vm->_global->_primaryHeight = height;
 		_vm->_global->_mouseMaxRow = height;
 		sprSize = 0;
-
 	} else {
-		vidMem = 0;
 		sprSize = Video::getRectSize(width, height, flagsAnd2, vidMode);
 		if (flagsAnd2)
 			someFlags += 0x80;
 	}
 	if (flags & PRIMARY_SURFACE) {
 		descPtr = _vm->_global->_pPrimarySurfDesc;
-		vidMem = (byte *)malloc(320 * 200);
+		delete[] descPtr->vidPtr;
+		assert(descPtr);
+		vidMem = new byte[320 * 200];
 	} else {
-		if (flags & DISABLE_SPR_ALLOC)
-			descPtr = (SurfaceDesc *)malloc(sizeof(SurfaceDesc));
-		else
-			descPtr = (SurfaceDesc *)malloc(sizeof(SurfaceDesc) + sprSize);
+		if (flags & DISABLE_SPR_ALLOC) {
+			descPtr = new SurfaceDesc;
+			// this case causes vidPtr to be set to invalid memory
+			assert(false);
+		} else {
+			descPtr = new SurfaceDesc;
+			descPtr->vidPtr = new byte[sprSize];
+			vidMem = descPtr->vidPtr;
+		}
 	}
 	if (descPtr == 0)
 		return 0;
@@ -137,8 +141,6 @@
 	descPtr->height = height;
 	descPtr->flag = someFlags;
 	descPtr->vidMode = vidMode;
-	if (vidMem == 0)
-		vidMem = ((byte *)descPtr) + sizeof(SurfaceDesc);
 	descPtr->vidPtr = vidMem;
 
 	descPtr->reserved1 = 0;
@@ -147,11 +149,11 @@
 }
 
 void Video::freeSurfDesc(SurfaceDesc * surfDesc) {
-	_vm->_global->_sprAllocated--;
-	if (surfDesc != _vm->_global->_pPrimarySurfDesc)
-		free(surfDesc);
-	else
-		free(surfDesc->vidPtr);
+	delete[] surfDesc->vidPtr;
+	if (surfDesc != _vm->_global->_pPrimarySurfDesc) {
+		_vm->_global->_sprAllocated--;
+		delete surfDesc;
+	}
 }
 
 int16 Video::clampValue(int16 val, int16 max) {
@@ -302,7 +304,7 @@
 		return;
 
 	if ((dest->vidMode & 0x7f) != 0x13)
-		error("Video::drawPackedSprite: Vide mode 0x%x is not fully supported!",
+		error("Video::drawPackedSprite: Video mode 0x%x is not fully supported!",
 		    dest->vidMode & 0x7f);
 
 	_videoDriver->drawPackedSprite(sprBuf, width, height, x, y, transp, dest);
@@ -378,13 +380,6 @@
 
 void Video::initPrimary(int16 mode) {
 	int16 old;
-	if (_vm->_global->_curPrimaryDesc) {
-		Video::freeSurfDesc(_vm->_global->_curPrimaryDesc);
-		Video::freeSurfDesc(_vm->_global->_allocatedPrimary);
-
-		_vm->_global->_curPrimaryDesc = 0;
-		_vm->_global->_allocatedPrimary = 0;
-	}
 	if (mode != 0x13 && mode != 3 && mode != -1)
 		error("Video::initPrimary: Video mode 0x%x is not supported!",
 		    mode);
@@ -450,7 +445,7 @@
 		    srcHeight - 1, x, y, transp);
 		return 1;
 	} else {
-		memBuffer = (byte *)malloc(4114);
+		memBuffer = new byte[4114];
 		if (memBuffer == 0)
 			return 0;
 
@@ -520,13 +515,13 @@
 						destPtr = linePtr;
 						curHeight++;
 						if (curHeight >= srcHeight) {
-							free(memBuffer);
+							delete[] memBuffer;
 							return 1;
 						}
 					}
 					sourceLeft--;
 					if (sourceLeft == 0) {
-						free(memBuffer);
+						delete[] memBuffer;
 						return 1;
 					}
 					memBuffer[bufPos] = temp;
@@ -536,7 +531,7 @@
 			}
 		}
 	}
-	free(memBuffer);
+	delete[] memBuffer;
 	return 1;
 }
 

Index: video.h
===================================================================
RCS file: /cvsroot/scummvm/scummvm/gob/video.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- video.h	18 Jan 2006 17:39:34 -0000	1.12
+++ video.h	29 Jan 2006 02:27:10 -0000	1.13
@@ -40,7 +40,7 @@
 
 class Video {
 public:
-	typedef struct SurfaceDesc_t {
+	struct SurfaceDesc {
 		int16 width;
 		int16 height;
 		int8 reserved1;
@@ -48,11 +48,11 @@
 		int16 vidMode;
 		byte *vidPtr;
 		int16 reserved2;
-		SurfaceDesc_t() : width(0), height(0), reserved1(0), flag(0),
+		SurfaceDesc() : width(0), height(0), reserved1(0), flag(0),
 						  vidMode(0), vidPtr(0), reserved2(0) {}
-	} SurfaceDesc;
+	};
 
-	typedef struct FontDesc_t {
+	struct FontDesc {
 		char *dataPtr;
 		int8 itemWidth;
 		int8 itemHeight;
@@ -61,9 +61,9 @@
 		int8 itemSize;
 		int8 bitWidth;
 		void *extraData;
-		FontDesc_t() : dataPtr(0), itemWidth(0), itemHeight(0), startItem(0),
+		FontDesc() : dataPtr(0), itemWidth(0), itemHeight(0), startItem(0),
 			               endItem(0), itemSize(0), bitWidth(0) {}
-	} FontDesc;
+	};
 
 #define GDR_VERSION	4
 
@@ -73,20 +73,20 @@
 
 #pragma START_PACK_STRUCTS
 
-	typedef struct Color {
+	struct Color {
 		byte red;
 		byte green;
 		byte blue;
-	} GCC_PACK Color;
+	} GCC_PACK;
 
 #pragma END_PACK_STRUCTS
 
-	typedef struct PalDesc {
+	struct PalDesc {
 		Color *vgaPal;
 		int16 *unused1;
 		int16 *unused2;
 		PalDesc() : vgaPal(0), unused1(0), unused2(0) {}
-	} PalDesc;
+	};
 
 	Video(class GobEngine *vm);
 	int32 getRectSize(int16 width, int16 height, int16 flag, int16 mode);





More information about the Scummvm-git-logs mailing list