aboutsummaryrefslogtreecommitdiff
path: root/engines/cge2/spare.cpp
diff options
context:
space:
mode:
authoruruk2014-07-03 00:39:23 +0200
committeruruk2014-07-04 12:58:46 +0200
commitb9dc93c451d891704d828e3c384aae015a63ff40 (patch)
treec3acbd4063db352acd98a37ee9988261a4cc8094 /engines/cge2/spare.cpp
parent1305bc8aa8b46459dfea08ad52309a57dbda64d8 (diff)
downloadscummvm-rg350-b9dc93c451d891704d828e3c384aae015a63ff40.tar.gz
scummvm-rg350-b9dc93c451d891704d828e3c384aae015a63ff40.tar.bz2
scummvm-rg350-b9dc93c451d891704d828e3c384aae015a63ff40.zip
CGE2: Heavily rework memory management of Sprites.
Hopefully it will solve a bunch of memory leak problems. Now Spare is a central container, which stores pointers to every Sprite currently used by the engine. Because of that, there's no more need for Queue's clear(). In case of snKill(), it's just a safeguard, since it's only used by the engine to "kill" the speech bubbles, but we will check Spare anyway, so it's the safest this way.
Diffstat (limited to 'engines/cge2/spare.cpp')
-rw-r--r--engines/cge2/spare.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/engines/cge2/spare.cpp b/engines/cge2/spare.cpp
index d202be9aff..dde37d4fbe 100644
--- a/engines/cge2/spare.cpp
+++ b/engines/cge2/spare.cpp
@@ -35,6 +35,9 @@ void Spare::sync(Common::Serializer &s) {
}
void Spare::clear() {
+ for (int i = 0; i < _container.size(); i++)
+ delete _container[i];
+
_container.clear();
}