From 88913c0139ac6d1dfb356d3048702b7bc8ef4079 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 20 Jun 2011 00:59:48 +0200 Subject: ALL: Remove trailing whitespaces This tries to make our code a bit more compliant with our code formatting conventions. For future use, this is the command I used: git ls-files "*.cpp" "*.h" | xargs sed -i -e 's/[ \t]*$//' --- engines/lure/res_struct.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/lure') diff --git a/engines/lure/res_struct.h b/engines/lure/res_struct.h index 49b6ef78ba..8d6c557297 100644 --- a/engines/lure/res_struct.h +++ b/engines/lure/res_struct.h @@ -470,7 +470,7 @@ public: bool isEmpty() const { return _actions.begin() == _actions.end(); } void clear() { _actions.clear(); } CurrentActionEntry &top() { return **_actions.begin(); } - CurrentActionEntry &bottom() { + CurrentActionEntry &bottom() { ActionsList::iterator i = _actions.end(); --i; return **i; -- cgit v1.2.3 From 2f200ac49322ff8ccd13c5e8b7a22abbf6ff2610 Mon Sep 17 00:00:00 2001 From: Julien Date: Sat, 4 Jun 2011 03:43:16 +0800 Subject: ANALYSIS: Fix potential memory leak when using realloc When reallocation is unsuccessful, the passed buffer is not freed. In this case, assigning the result (NULL) will result in a leak of the original memory buffer. See http://msdn.microsoft.com/en-us/library/kkedhy7c.aspx --- engines/lure/memory.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'engines/lure') diff --git a/engines/lure/memory.cpp b/engines/lure/memory.cpp index c5c28fa8bc..137a8f6bee 100644 --- a/engines/lure/memory.cpp +++ b/engines/lure/memory.cpp @@ -93,8 +93,12 @@ void MemoryBlock::copyFrom(const byte *src, uint32 srcPos, uint32 destPos, uint3 void MemoryBlock::reallocate(uint32 size1) { _size = size1; - _data = (byte *) realloc(_data, size1); - if (!_data) error ("Failed reallocating memory block"); + + byte *tmp = (byte *) realloc(_data, size1); + if (!tmp) + error ("[MemoryBlock::reallocate] Failed reallocating memory block"); + + _data = tmp; } } // End of namespace Lure -- cgit v1.2.3 From 9ff993382e17d1d7aef96105ad5fa2fe35043b7a Mon Sep 17 00:00:00 2001 From: Julien Date: Sun, 5 Jun 2011 06:03:54 +0800 Subject: LURE: Allocate debug strings buffer on the heap --- engines/lure/debugger.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'engines/lure') diff --git a/engines/lure/debugger.cpp b/engines/lure/debugger.cpp index 68410875f7..ef4a22f73a 100644 --- a/engines/lure/debugger.cpp +++ b/engines/lure/debugger.cpp @@ -549,14 +549,19 @@ bool Debugger::cmd_showAnim(int argc, const char **argv) { } bool Debugger::cmd_saveStrings(int argc, const char **argv) { - StringData &strings = StringData::getReference(); - char buffer[32768]; - if (argc != 2) { DebugPrintf("strings \n"); return true; } + StringData &strings = StringData::getReference(); + + char *buffer = (char *)malloc(32768); + if (!buffer) { + DebugPrintf("Cannot allocate strings buffer\n"); + return true; + } + uint16 id = strToInt(argv[1]); strings.getString(id, buffer, NULL, NULL); DebugPrintf("%s\n", buffer); @@ -577,6 +582,9 @@ bool Debugger::cmd_saveStrings(int argc, const char **argv) { DebugPrintf("Done\n"); */ + + free(buffer); + return true; } -- cgit v1.2.3 From aa0f307e06e5aae3b12f9f15b350dc81b30d61de Mon Sep 17 00:00:00 2001 From: Ori Avtalion Date: Tue, 28 Jun 2011 02:06:23 +0300 Subject: ALL: Require DECLARE_SINGLETON to be used in the Common namepsace Silences the clang warning: static data member specialization of '_singleton' must originally be declared in namespace 'Common'; accepted as a C++0x extension [-Wc++0x-extensions] Wrapping "namespace Common {}" around the macro assignment causes clang to complain about a spurious semicolon, and removing the semicolon at the end of the macro causes some editors to misbehave. Changing the requirement of using the macro in one namespace (the global) to another (Common) seems a small price to pay to silence a warning. --- engines/lure/sound.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'engines/lure') diff --git a/engines/lure/sound.cpp b/engines/lure/sound.cpp index cf28e0bb74..85b86a8400 100644 --- a/engines/lure/sound.cpp +++ b/engines/lure/sound.cpp @@ -31,7 +31,9 @@ #include "common/endian.h" #include "audio/midiparser.h" +namespace Common { DECLARE_SINGLETON(Lure::SoundManager); +} namespace Lure { -- cgit v1.2.3 From 5dd8f2575b0f39dea909db73afc83f16732b2a5e Mon Sep 17 00:00:00 2001 From: eriktorbjorn Date: Thu, 30 Jun 2011 23:47:10 +0200 Subject: JANITORIAL: Silence a couple of "variable set but not used" warnings. --- engines/lure/disk.cpp | 3 +-- engines/lure/hotspots.cpp | 3 +-- 2 files changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/lure') diff --git a/engines/lure/disk.cpp b/engines/lure/disk.cpp index 9212508be0..552da73f18 100644 --- a/engines/lure/disk.cpp +++ b/engines/lure/disk.cpp @@ -98,7 +98,6 @@ void Disk::openFile(uint8 fileNum) { error("Could not open %s", sFilename); char buffer[7]; - uint32 bytesRead; // If it's the support file, then move to the correct language area @@ -130,7 +129,7 @@ void Disk::openFile(uint8 fileNum) { // Validate the header - bytesRead = _fileHandle->read(buffer, 6); + _fileHandle->read(buffer, 6); buffer[6] = '\0'; if (strcmp(buffer, HEADER_IDENT_STRING) != 0) error("The file %s was not a valid VGA file", sFilename); diff --git a/engines/lure/hotspots.cpp b/engines/lure/hotspots.cpp index 97fbaa72ae..f38bac6e12 100644 --- a/engines/lure/hotspots.cpp +++ b/engines/lure/hotspots.cpp @@ -763,7 +763,7 @@ void Hotspot::showMessage(uint16 messageId, uint16 destCharacterId) { MemoryBlock *data = res.messagesData(); Hotspot *hotspot; uint8 *msgData = (uint8 *) data->data(); - uint16 v2, idVal; + uint16 idVal; messageId &= 0x7fff; // Skip through header to find table for given character @@ -781,7 +781,6 @@ void Hotspot::showMessage(uint16 messageId, uint16 destCharacterId) { // Scan through secondary list uint16 *v = (uint16 *) (msgData + READ_LE_UINT16(msgData + idx + sizeof(uint16))); - v2 = 0; while ((idVal = READ_LE_UINT16(v)) != 0xffff) { ++v; if (READ_LE_UINT16(v) == messageId) break; -- cgit v1.2.3