From 4203819b39d484a74da0ccbbb86e28989328bd80 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Thu, 1 Mar 2007 17:13:23 +0000 Subject: Got rid of another use of File::incRef/decRef svn-id: r25917 --- engines/sword2/resman.cpp | 10 ++++------ engines/sword2/resman.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) (limited to 'engines') diff --git a/engines/sword2/resman.cpp b/engines/sword2/resman.cpp index cd482cc9f5..d016a5ad18 100644 --- a/engines/sword2/resman.cpp +++ b/engines/sword2/resman.cpp @@ -425,10 +425,7 @@ Common::File *ResourceManager::openCluFile(uint16 fileNum) { void ResourceManager::readCluIndex(uint16 fileNum, Common::File *file) { if (_resFiles[fileNum].entryTab == NULL) { // we didn't read from this file before, get its index table - if (file == NULL) - file = openCluFile(fileNum); - else - file->incRef(); + assert(file); // 1st DWORD of a cluster is an offset to the look-up table uint32 table_offset = file->readUint32LE(); @@ -446,7 +443,6 @@ void ResourceManager::readCluIndex(uint16 fileNum, Common::File *file) { for (int tabCnt = 0; tabCnt < _resFiles[fileNum].numEntries * 2; tabCnt++) _resFiles[fileNum].entryTab[tabCnt] = FROM_LE_32(_resFiles[fileNum].entryTab[tabCnt]); #endif - file->decRef(); } } @@ -491,7 +487,9 @@ uint32 ResourceManager::fetchLen(uint32 res) { // open the cluster file if (_resFiles[parent_res_file].entryTab == NULL) { - readCluIndex(parent_res_file); + Common::File *file = openCluFile(parent_res_file); + readCluIndex(parent_res_file, file); + delete file; } return _resFiles[parent_res_file].entryTab[actual_res * 2 + 1]; } diff --git a/engines/sword2/resman.h b/engines/sword2/resman.h index 5afa292521..c1a8f3f117 100644 --- a/engines/sword2/resman.h +++ b/engines/sword2/resman.h @@ -54,7 +54,7 @@ struct ResourceFile { class ResourceManager { private: Common::File *openCluFile(uint16 fileNum); - void readCluIndex(uint16 fileNum, Common::File *file = NULL); + void readCluIndex(uint16 fileNum, Common::File *file); void removeFromCacheList(Resource *res); void addToCacheList(Resource *res); void checkMemUsage(); -- cgit v1.2.3