aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStrangerke2014-07-08 09:44:51 +0200
committerStrangerke2014-07-08 09:45:22 +0200
commita73aea1ce8cb72607d258063f48b8540925b79e2 (patch)
treea11363e74aa0c42b688e8b11da84fe04d8260aee
parent3935a427f94c7619c56976db3c8c4aeca1df500b (diff)
downloadscummvm-rg350-a73aea1ce8cb72607d258063f48b8540925b79e2.tar.gz
scummvm-rg350-a73aea1ce8cb72607d258063f48b8540925b79e2.tar.bz2
scummvm-rg350-a73aea1ce8cb72607d258063f48b8540925b79e2.zip
CGE2: Fix GCC warning, rewrite Text::clear()
-rw-r--r--engines/cge2/text.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/engines/cge2/text.cpp b/engines/cge2/text.cpp
index 5826f6e5bb..e1b25525c3 100644
--- a/engines/cge2/text.cpp
+++ b/engines/cge2/text.cpp
@@ -49,8 +49,10 @@ Text::Text(CGE2Engine *vm, const char *fname) : _vm(vm) {
_cache[_size]._text = nullptr;
}
load();
- _cache[_txtCount - 1]._ref = 0;
- _cache[_txtCount - 1]._text = "";
+
+ _cache[_txtCount - 1]._ref = -1;
+ _cache[_txtCount - 1]._text = new char[3];
+ strcpy(_cache[_txtCount - 1]._text, "");
}
Text::~Text() {
@@ -83,11 +85,11 @@ int16 Text::count() {
}
void Text::clear() {
- for (Handler *p = _cache, *q = p + _size; p < q; p++) {
- if (p->_ref) {
- p->_ref = 0;
- delete[] p->_text;
- p->_text = nullptr;
+ for (int i = 0; i < _txtCount; i++) {
+ if (_cache[i]._ref) {
+ _cache[i]._ref = 0;
+ delete[] _cache[i]._text;
+ _cache[i]._text = nullptr;
}
}
}