[Scummvm-cvs-logs] SF.net SVN: scummvm:[47275] scummvm/trunk/engines/sci/engine
lordhoto at users.sourceforge.net
lordhoto at users.sourceforge.net
Tue Jan 12 21:19:48 CET 2010
Revision: 47275
http://scummvm.svn.sourceforge.net/scummvm/?rev=47275&view=rev
Author: lordhoto
Date: 2010-01-12 20:19:45 +0000 (Tue, 12 Jan 2010)
Log Message:
-----------
Fix some memory leaks caused by never freeing the allocated memory, which is pointed at by KernelFuncWithSignature::signature.
Modified Paths:
--------------
scummvm/trunk/engines/sci/engine/kernel.cpp
scummvm/trunk/engines/sci/engine/kernel.h
Modified: scummvm/trunk/engines/sci/engine/kernel.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.cpp 2010-01-12 20:08:17 UTC (rev 47274)
+++ scummvm/trunk/engines/sci/engine/kernel.cpp 2010-01-12 20:19:45 UTC (rev 47275)
@@ -392,11 +392,17 @@
}
Kernel::~Kernel() {
+ for (KernelFuncsContainer::iterator i = _kernelFuncs.begin(); i != _kernelFuncs.end(); ++i)
+ // TODO: Doing a const_cast is not that nice actually... But since KernelFuncWithSignature
+ // keeps the signature member as "const char *" there is no way around it.
+ // Think of a clever way to avoid this.
+ free(const_cast<char *>(i->signature));
}
uint Kernel::getSelectorNamesSize() const {
return _selectorNames.size();
}
+
const Common::String &Kernel::getSelectorName(uint selector) const {
return _selectorNames[selector];
}
@@ -404,6 +410,7 @@
uint Kernel::getKernelNamesSize() const {
return _kernelNames.size();
}
+
const Common::String &Kernel::getKernelName(uint number) const {
// FIXME: The following check is a temporary workaround for
// an issue leading to crashes when using the debugger's backtrace
@@ -504,7 +511,7 @@
if (!src)
return; // NULL signature: Nothing to do
- result = (char*)malloc(strlen(*s) + 1);
+ result = (char *)malloc(strlen(*s) + 1);
while (*src) {
char c;
@@ -554,11 +561,10 @@
ellipsis = 1;
break;
- default: {
+ default:
error("INTERNAL ERROR when compiling kernel function signature '%s': (%02x) not understood (aka"
" '%c')\n", *s, c, c);
}
- }
} while (*src && (*src == KSIG_SPEC_ELLIPSIS || (c < 'a' && c != KSIG_SPEC_ANY)));
// To handle sum types
Modified: scummvm/trunk/engines/sci/engine/kernel.h
===================================================================
--- scummvm/trunk/engines/sci/engine/kernel.h 2010-01-12 20:08:17 UTC (rev 47274)
+++ scummvm/trunk/engines/sci/engine/kernel.h 2010-01-12 20:19:45 UTC (rev 47275)
@@ -84,7 +84,8 @@
void dumpScriptClass(char *data, int seeker, int objsize);
SelectorCache _selectorCache; /**< Shortcut list for important selectors */
- Common::Array<KernelFuncWithSignature> _kernelFuncs; /**< Table of kernel functions */
+ typedef Common::Array<KernelFuncWithSignature> KernelFuncsContainer;
+ KernelFuncsContainer _kernelFuncs; /**< Table of kernel functions */
private:
/**
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list