[Scummvm-git-logs] scummvm master -> 0f17c9de479e8607707e6ab2a184d0e141f39904
dreammaster
dreammaster at scummvm.org
Sun Nov 6 02:44:58 CET 2016
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
0f17c9de47 TITANIC: Free allocated class type definitions on exit
Commit: 0f17c9de479e8607707e6ab2a184d0e141f39904
https://github.com/scummvm/scummvm/commit/0f17c9de479e8607707e6ab2a184d0e141f39904
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2016-11-05T21:44:51-04:00
Commit Message:
TITANIC: Free allocated class type definitions on exit
Changed paths:
engines/titanic/core/saveable_object.cpp
engines/titanic/core/saveable_object.h
diff --git a/engines/titanic/core/saveable_object.cpp b/engines/titanic/core/saveable_object.cpp
index c4fdb49..b0009c3 100644
--- a/engines/titanic/core/saveable_object.cpp
+++ b/engines/titanic/core/saveable_object.cpp
@@ -421,14 +421,15 @@ CSaveableObject *ClassDef::create() {
/*------------------------------------------------------------------------*/
-Common::HashMap<Common::String, CSaveableObject::CreateFunction> *
- CSaveableObject::_classList = nullptr;
-Common::List<ClassDef *> *CSaveableObject::_classDefs;
+CSaveableObject::ClassListMap *CSaveableObject::_classList = nullptr;
+CSaveableObject::ClassDefList *CSaveableObject::_classDefs;
+CSaveableObject::VoidArray *CSaveableObject::_typesToFree;
#define DEFFN(T) CSaveableObject *Function##T() { return new T(); } \
ClassDef *T::_type
#define ADDFN(CHILD, PARENT) \
CHILD::_type = new TypeTemplate<CHILD>(#CHILD, PARENT::_type); \
+ _typesToFree->push_back(CHILD::_type); \
(*_classList)[#CHILD] = Function##CHILD
DEFFN(CArm);
@@ -1020,8 +1021,9 @@ DEFFN(CStarControl);
DEFFN(CTimeEventInfo);
void CSaveableObject::initClassList() {
- _classDefs = new Common::List<ClassDef *>();
- _classList = new Common::HashMap<Common::String, CreateFunction>();
+ _classDefs = new ClassDefList();
+ _classList = new ClassListMap();
+ _typesToFree = new VoidArray();
ADDFN(CArm, CCarry);
ADDFN(CAuditoryCentre, CBrain);
ADDFN(CBowlEar, CEar);
@@ -1617,12 +1619,16 @@ void CSaveableObject::initClassList() {
}
void CSaveableObject::freeClassList() {
- Common::List<ClassDef *>::iterator i;
+ ClassDefList::iterator i;
for (i = _classDefs->begin(); i != _classDefs->end(); ++i)
delete *i;
+ for (uint idx = 0; idx < _typesToFree->size(); ++idx)
+ delete (*_typesToFree)[idx];
+
delete _classDefs;
delete _classList;
+ delete _typesToFree;
}
CSaveableObject *CSaveableObject::createInstance(const Common::String &name) {
diff --git a/engines/titanic/core/saveable_object.h b/engines/titanic/core/saveable_object.h
index 4c7c1a7..0591f09 100644
--- a/engines/titanic/core/saveable_object.h
+++ b/engines/titanic/core/saveable_object.h
@@ -59,8 +59,12 @@ public:
class CSaveableObject {
typedef CSaveableObject *(*CreateFunction)();
private:
- static Common::List<ClassDef *> *_classDefs;
- static Common::HashMap<Common::String, CreateFunction> *_classList;
+ typedef Common::List<ClassDef *> ClassDefList;
+ typedef Common::HashMap<Common::String, CreateFunction> ClassListMap;
+ typedef Common::Array<void *> VoidArray;
+ static ClassDefList *_classDefs;
+ static ClassListMap *_classList;
+ static VoidArray *_typesToFree;
public:
/**
* Sets up the list of saveable object classes
More information about the Scummvm-git-logs
mailing list