diff options
author | Paul Gilbert | 2016-05-11 21:36:45 -0400 |
---|---|---|
committer | Paul Gilbert | 2016-07-10 16:39:21 -0400 |
commit | 2f2397f7df053fb17badd93b15ea5270892232b2 (patch) | |
tree | 110813bb22f4c40280c88e8f5a835575c9b5ff7a /engines/titanic/true_talk | |
parent | 7700923298da4002a5d0baf28913a46e7e0fcf59 (diff) | |
download | scummvm-rg350-2f2397f7df053fb17badd93b15ea5270892232b2.tar.gz scummvm-rg350-2f2397f7df053fb17badd93b15ea5270892232b2.tar.bz2 scummvm-rg350-2f2397f7df053fb17badd93b15ea5270892232b2.zip |
TITANIC: Added STVocab destructor
Diffstat (limited to 'engines/titanic/true_talk')
-rw-r--r-- | engines/titanic/true_talk/st_vocab.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/true_talk/st_vocab.h | 1 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_word.cpp | 8 | ||||
-rw-r--r-- | engines/titanic/true_talk/tt_word.h | 5 |
4 files changed, 22 insertions, 0 deletions
diff --git a/engines/titanic/true_talk/st_vocab.cpp b/engines/titanic/true_talk/st_vocab.cpp index df683c7ad7..8ea2b53871 100644 --- a/engines/titanic/true_talk/st_vocab.cpp +++ b/engines/titanic/true_talk/st_vocab.cpp @@ -31,6 +31,14 @@ STVocab::STVocab(int val): _pHead(nullptr), _pTail(nullptr), _word(nullptr), _field14 = load("STVOCAB.TXT"); } +STVocab::~STVocab() { + if (_pHead) { + _pHead->deleteSiblings(); + delete _pHead; + _pHead = _pTail = nullptr; + } +} + int STVocab::load(const CString &name) { SimpleFile *file = g_vm->_exeResources._owner->openResource(name); int result = 0; diff --git a/engines/titanic/true_talk/st_vocab.h b/engines/titanic/true_talk/st_vocab.h index 68ce86b7cf..6a86825ef7 100644 --- a/engines/titanic/true_talk/st_vocab.h +++ b/engines/titanic/true_talk/st_vocab.h @@ -55,6 +55,7 @@ private: TTword *findWord(const TTString &str); public: STVocab(int val); + ~STVocab(); }; } // End of namespace Titanic diff --git a/engines/titanic/true_talk/tt_word.cpp b/engines/titanic/true_talk/tt_word.cpp index 53d4bd8078..b7309b2c63 100644 --- a/engines/titanic/true_talk/tt_word.cpp +++ b/engines/titanic/true_talk/tt_word.cpp @@ -32,6 +32,14 @@ TTword::TTword(TTString &str, int mode, int val2) : _string(str), _status = str.getStatus() == SS_VALID ? SS_VALID : SS_5; } +void TTword::deleteSiblings() { + while (_pNext) { + TTword *next = _pNext; + _pNext = next->_pNext; + delete next; + } +} + int TTword::readSyn(SimpleFile *file) { CString str; int mode, val1; diff --git a/engines/titanic/true_talk/tt_word.h b/engines/titanic/true_talk/tt_word.h index 850b6957f8..ad2ddeb987 100644 --- a/engines/titanic/true_talk/tt_word.h +++ b/engines/titanic/true_talk/tt_word.h @@ -52,6 +52,11 @@ public: TTword(TTString &str, int mode, int val2); /** + * Delete any following words chained to the word + */ + void deleteSiblings(); + + /** * Read in a synonym for the given word */ int readSyn(SimpleFile *file); |