aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/cine/anim.cpp17
-rw-r--r--engines/cine/bg.cpp14
-rw-r--r--engines/cine/msg.cpp7
-rw-r--r--engines/cine/object.cpp6
-rw-r--r--engines/cine/prc.cpp8
-rw-r--r--engines/cine/rel.cpp6
6 files changed, 45 insertions, 13 deletions
diff --git a/engines/cine/anim.cpp b/engines/cine/anim.cpp
index 609050426e..8163f264ce 100644
--- a/engines/cine/anim.cpp
+++ b/engines/cine/anim.cpp
@@ -416,6 +416,8 @@ void loadSpl(const char *resourceName) {
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 @@ void loadSplAbs(const char *resourceName, uint16 idx) {
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 @@ void loadMsk(const char *resourceName) {
animDataTable[entry].frameIdx = i;
strcpy(animDataTable[entry].name, currentPartName);
}
+
+ free(dataPtr);
}
void loadAni(const char *resourceName) {
@@ -555,6 +561,8 @@ void loadAni(const char *resourceName) {
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 @@ void loadSet(const char *resourceName) {
animDataTable[entry].frameIdx = i;
strcpy(animDataTable[entry].name, currentPartName);
}
+
+ free(dataPtr);
}
void loadSetAbs(const char *resourceName, uint16 idx) {
@@ -841,6 +851,8 @@ void loadSetAbs(const char *resourceName, uint16 idx) {
animDataTable[entry].frameIdx = i;
strcpy(animDataTable[entry].name, currentPartName);
}
+
+ free(dataPtr);
}
void loadSeq(const char *resourceName) {
@@ -854,6 +866,8 @@ void loadSeq(const char *resourceName) {
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 @@ void loadSeqAbs(const char *resourceName, uint16 idx) {
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 @@ void loadResourcesFromSave() {
}
}
+ free(dataPtr);
}
}
diff --git a/engines/cine/bg.cpp b/engines/cine/bg.cpp
index 41291dea92..f17aedfe23 100644
--- a/engines/cine/bg.cpp
+++ b/engines/cine/bg.cpp
@@ -39,10 +39,11 @@ void loadCtHigh(byte * currentPtr) {
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 @@ byte loadCt(const char *ctName) {
gfxConvertSpriteToRaw(page3Raw, ptr + 0x80, 160, 200);
}
+ free(dataPtr);
return 0;
}
@@ -81,10 +83,12 @@ void loadBgHigh(const char *currentPtr) {
}
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 @@ byte loadBg(const char *bgName) {
gfxResetRawPage(page2Raw);
gfxConvertSpriteToRaw(page2Raw, ptr, 160, 200);
}
+ free(dataPtr);
return 0;
}
@@ -110,10 +115,12 @@ byte currentAdditionalBgIdx = 0;
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 @@ void addBackground(const char *bgName, uint16 bgIdx) {
ptr += 32;
gfxConvertSpriteToRaw(additionalBgTable[bgIdx], ptr, 160, 200);
}
+ free(dataPtr);
}
} // End of namespace Cine
diff --git a/engines/cine/msg.cpp b/engines/cine/msg.cpp
index 691c024259..0947cbd45a 100644
--- a/engines/cine/msg.cpp
+++ b/engines/cine/msg.cpp
@@ -34,7 +34,7 @@ uint16 messageCount;
void loadMsg(char *pMsgName) {
uint16 i;
- byte *ptr;
+ byte *ptr, *dataPtr;
checkDataDisk(-1);
@@ -45,14 +45,13 @@ void loadMsg(char *pMsgName) {
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 @@ void loadMsg(char *pMsgName) {
ptr += messageTable[i].len;
}
}
+
+ free(dataPtr);
}
} // End of namespace Cine
diff --git a/engines/cine/object.cpp b/engines/cine/object.cpp
index eafd197d53..89a0d6bb35 100644
--- a/engines/cine/object.cpp
+++ b/engines/cine/object.cpp
@@ -61,11 +61,11 @@ void loadObject(char *pObjectName) {
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 @@ void loadObject(char *pObjectName) {
objectTable[i].costume = 0;
}
}
+
+ free(dataPtr);
}
int8 removeOverlayElement(uint16 objIdx, uint16 param) {
diff --git a/engines/cine/prc.cpp b/engines/cine/prc.cpp
index bb7fbfc9d0..4a78e22452 100644
--- a/engines/cine/prc.cpp
+++ b/engines/cine/prc.cpp
@@ -63,7 +63,7 @@ void freePrcLinkedList(void) {
void loadPrc(const char *pPrcName) {
byte i;
uint16 numScripts;
- const byte *scriptPtr;
+ byte *scriptPtr, *dataPtr;
assert(pPrcName);
@@ -85,9 +85,9 @@ void loadPrc(const char *pPrcName) {
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 @@ void loadPrc(const char *pPrcName) {
}
}
+ free(dataPtr);
+
#ifdef DUMP_SCRIPTS
{
diff --git a/engines/cine/rel.cpp b/engines/cine/rel.cpp
index 2586882ff8..cdbb9def06 100644
--- a/engines/cine/rel.cpp
+++ b/engines/cine/rel.cpp
@@ -58,7 +58,7 @@ void releaseObjectScripts(void) {
void loadRel(char *pRelName) {
uint16 numEntry;
uint16 i;
- byte *ptr;
+ byte *ptr, *dataPtr;
checkDataDisk(-1);
@@ -70,7 +70,7 @@ void loadRel(char *pRelName) {
}
}
- ptr = readBundleFile(findFileInBundle(pRelName));
+ ptr = dataPtr = readBundleFile(findFileInBundle(pRelName));
setMouseCursor(MOUSE_CURSOR_DISK);
@@ -95,6 +95,8 @@ void loadRel(char *pRelName) {
ptr += relTable[i].size;
}
}
+
+ free(dataPtr);
#ifdef DUMP_SCRIPTS