[Scummvm-cvs-logs] SF.net SVN: scummvm:[54165] scummvm/trunk/engines/mohawk
mthreepwood at users.sourceforge.net
mthreepwood at users.sourceforge.net
Tue Nov 9 19:52:29 CET 2010
Revision: 54165
http://scummvm.svn.sourceforge.net/scummvm/?rev=54165&view=rev
Author: mthreepwood
Date: 2010-11-09 18:52:29 +0000 (Tue, 09 Nov 2010)
Log Message:
-----------
MOHAWK: Fix cache memory leak and some formatting
Modified Paths:
--------------
scummvm/trunk/engines/mohawk/resource_cache.cpp
scummvm/trunk/engines/mohawk/resource_cache.h
Modified: scummvm/trunk/engines/mohawk/resource_cache.cpp
===================================================================
--- scummvm/trunk/engines/mohawk/resource_cache.cpp 2010-11-09 18:38:35 UTC (rev 54164)
+++ scummvm/trunk/engines/mohawk/resource_cache.cpp 2010-11-09 18:52:29 UTC (rev 54165)
@@ -43,16 +43,17 @@
debugC(kDebugCache, "Clearing Cache...");
- // TODO: Not sure if need to explicitly delete DataObject.data element ie.
- // returned by readStream method here.
- store.clear();
+ for (uint32 i = 0; i < _store.size(); i++)
+ delete _store[i].data;
+
+ _store.clear();
}
void ResourceCache::add(uint32 tag, uint16 id, Common::SeekableReadStream *data) {
if (!enabled)
return;
- debugC(kDebugCache, "Adding item %d - tag 0x%04X id %d", store.size(), tag, id);
+ debugC(kDebugCache, "Adding item %d - tag 0x%04X id %d", _store.size(), tag, id);
DataObject current;
current.tag = tag;
@@ -60,7 +61,7 @@
uint32 dataCurPos = data->pos();
current.data = data->readStream(data->size());
data->seek(dataCurPos);
- store.push_back(current);
+ _store.push_back(current);
}
// Returns NULL if not found
@@ -70,12 +71,12 @@
debugC(kDebugCache, "Searching for tag 0x%04X id %d", tag, id);
- for (uint32 i = 0; i < store.size(); i++) {
- if (tag == store[i].tag && id == store[i].id) {
+ for (uint32 i = 0; i < _store.size(); i++) {
+ if (tag == _store[i].tag && id == _store[i].id) {
debugC(kDebugCache, "Found cached tag 0x%04X id %u", tag, id);
- uint32 dataCurPos = store[i].data->pos();
- Common::SeekableReadStream *ret = store[i].data->readStream(store[i].data->size());
- store[i].data->seek(dataCurPos);
+ uint32 dataCurPos = _store[i].data->pos();
+ Common::SeekableReadStream *ret = _store[i].data->readStream(_store[i].data->size());
+ _store[i].data->seek(dataCurPos);
return ret;
}
}
Modified: scummvm/trunk/engines/mohawk/resource_cache.h
===================================================================
--- scummvm/trunk/engines/mohawk/resource_cache.h 2010-11-09 18:38:35 UTC (rev 54164)
+++ scummvm/trunk/engines/mohawk/resource_cache.h 2010-11-09 18:52:29 UTC (rev 54165)
@@ -51,7 +51,7 @@
Common::SeekableReadStream *data;
};
- Common::Array<DataObject> store;
+ Common::Array<DataObject> _store;
};
} // End of namespace Mohawk
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list