diff options
author | Einar Johan Trøan Sømåen | 2012-05-11 01:10:40 +0200 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2012-06-02 12:42:11 +0200 |
commit | ab98efe595b09ca44fc6c9283e7aedcdb4f2dd9a (patch) | |
tree | b87d41340e81c227142c6ea1f702a39f6dddd86f /engines/wintermute | |
parent | d4fd90e06479f76df274a80e20387e3c79515e3a (diff) | |
download | scummvm-rg350-ab98efe595b09ca44fc6c9283e7aedcdb4f2dd9a.tar.gz scummvm-rg350-ab98efe595b09ca44fc6c9283e7aedcdb4f2dd9a.tar.bz2 scummvm-rg350-ab98efe595b09ca44fc6c9283e7aedcdb4f2dd9a.zip |
WINTERMUTE: Make ScEngine use Common::String to avoid some double-frees.
Diffstat (limited to 'engines/wintermute')
-rw-r--r-- | engines/wintermute/scriptables/ScEngine.cpp | 8 | ||||
-rw-r--r-- | engines/wintermute/scriptables/ScEngine.h | 12 |
2 files changed, 8 insertions, 12 deletions
diff --git a/engines/wintermute/scriptables/ScEngine.cpp b/engines/wintermute/scriptables/ScEngine.cpp index 20716cfd04..0b19542beb 100644 --- a/engines/wintermute/scriptables/ScEngine.cpp +++ b/engines/wintermute/scriptables/ScEngine.cpp @@ -271,7 +271,7 @@ byte *CScEngine::GetCompiledScript(char *Filename, uint32 *OutSize, bool IgnoreC // is script in cache?
if (!IgnoreCache) {
for (i = 0; i < MAX_CACHED_SCRIPTS; i++) {
- if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename, Filename) == 0) {
+ if (_cachedScripts[i] && scumm_stricmp(_cachedScripts[i]->_filename.c_str(), Filename) == 0) {
_cachedScripts[i]->_timestamp = CBPlatform::GetTime();
*OutSize = _cachedScripts[i]->_size;
return _cachedScripts[i]->_buffer;
@@ -667,7 +667,7 @@ HRESULT CScEngine::AddBreakpoint(char *ScriptFilename, int Line) { CScBreakpoint *Bp = NULL;
for (int i = 0; i < _breakpoints.GetSize(); i++) {
- if (scumm_stricmp(_breakpoints[i]->_filename, ScriptFilename) == 0) {
+ if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) {
Bp = _breakpoints[i];
break;
}
@@ -693,7 +693,7 @@ HRESULT CScEngine::RemoveBreakpoint(char *ScriptFilename, int Line) { if (!Game->GetDebugMgr()->_enabled) return S_OK;
for (int i = 0; i < _breakpoints.GetSize(); i++) {
- if (scumm_stricmp(_breakpoints[i]->_filename, ScriptFilename) == 0) {
+ if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), ScriptFilename) == 0) {
for (int j = 0; j < _breakpoints[i]->_lines.GetSize(); j++) {
if (_breakpoints[i]->_lines[j] == Line) {
_breakpoints[i]->_lines.RemoveAt(j);
@@ -730,7 +730,7 @@ HRESULT CScEngine::RefreshScriptBreakpoints(CScScript *Script) { if (!Script || !Script->_filename) return E_FAIL;
for (int i = 0; i < _breakpoints.GetSize(); i++) {
- if (scumm_stricmp(_breakpoints[i]->_filename, Script->_filename) == 0) {
+ if (scumm_stricmp(_breakpoints[i]->_filename.c_str(), Script->_filename) == 0) {
Script->_breakpoints.Copy(_breakpoints[i]->_lines);
return S_OK;
}
diff --git a/engines/wintermute/scriptables/ScEngine.h b/engines/wintermute/scriptables/ScEngine.h index 7be147b39e..7ca9ec0771 100644 --- a/engines/wintermute/scriptables/ScEngine.h +++ b/engines/wintermute/scriptables/ScEngine.h @@ -62,34 +62,30 @@ public: _buffer = new byte[Size];
if (_buffer) memcpy(_buffer, Buffer, Size);
_size = Size;
- _filename = new char[strlen(Filename) + 1];
- if (_filename) strcpy(_filename, Filename);
+ _filename = Filename;
};
~CScCachedScript() {
if (_buffer) delete [] _buffer;
- if (_filename) delete [] _filename;
};
uint32 _timestamp;
byte *_buffer;
uint32 _size;
- char *_filename;
+ Common::String _filename;
};
class CScBreakpoint {
public:
CScBreakpoint(const char *Filename) {
- _filename = NULL;
- CBUtils::SetString(&_filename, Filename);
+ _filename = Filename;
}
~CScBreakpoint() {
- if (_filename) delete [] _filename;
_lines.RemoveAll();
}
- char *_filename;
+ Common::String _filename;
CBArray<int, int> _lines;
};
|