diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/fullpipe/statics.cpp | 6 | ||||
-rw-r--r-- | engines/fullpipe/utils.cpp | 24 | ||||
-rw-r--r-- | engines/fullpipe/utils.h | 4 |
3 files changed, 13 insertions, 21 deletions
diff --git a/engines/fullpipe/statics.cpp b/engines/fullpipe/statics.cpp index e87cf02a42..25aef988b5 100644 --- a/engines/fullpipe/statics.cpp +++ b/engines/fullpipe/statics.cpp @@ -1446,8 +1446,7 @@ Statics::Statics(Statics *src, bool reverse) : DynamicPhase(src, reverse) { _staticsName = src->_staticsName; } - _memfilename = (char *)calloc(strlen(src->_memfilename) + 1, 1); - strncpy(_memfilename, src->_memfilename, strlen(src->_memfilename) + 1); + _memfilename = src->_memfilename; _picture = new Picture(); } @@ -2236,8 +2235,7 @@ DynamicPhase::DynamicPhase(DynamicPhase *src, bool reverse) { _mfield_8 = src->_mfield_8; _mflags = src->_mflags; - _memfilename = (char *)calloc(strlen(src->_memfilename) + 1, 1); - strncpy(_memfilename, src->_memfilename, strlen(src->_memfilename) + 1); + _memfilename = src->_memfilename; _dataSize = src->_dataSize; _mfield_10 = src->_mfield_10; _libHandle = src->_libHandle; diff --git a/engines/fullpipe/utils.cpp b/engines/fullpipe/utils.cpp index cc85886a0f..f58249c04e 100644 --- a/engines/fullpipe/utils.cpp +++ b/engines/fullpipe/utils.cpp @@ -121,7 +121,6 @@ void MfcArchive::writePascalString(const char *str, bool twoByte) { } MemoryObject::MemoryObject() { - _memfilename = 0; _mfield_8 = 0; _mfield_C = 0; _mfield_10 = -1; @@ -134,19 +133,14 @@ MemoryObject::MemoryObject() { MemoryObject::~MemoryObject() { freeData(); - if (_memfilename) - free(_memfilename); } bool MemoryObject::load(MfcArchive &file) { debugC(5, kDebugLoading, "MemoryObject::load()"); _memfilename = file.readPascalString(); - if (char *p = strchr(_memfilename, '\\')) { - for (char *d = _memfilename; *p;) { - p++; - *d++ = *p; - } + while (_memfilename.contains('\\')) { + _memfilename.deleteChar(0); } if (g_fp->_currArchive) { @@ -157,10 +151,10 @@ bool MemoryObject::load(MfcArchive &file) { return true; } -void MemoryObject::loadFile(char *filename) { - debugC(5, kDebugLoading, "MemoryObject::loadFile(<%s>)", filename); +void MemoryObject::loadFile(Common::String filename) { + debugC(5, kDebugLoading, "MemoryObject::loadFile(<%s>)", filename.c_str()); - if (!*filename) + if (filename.empty()) return; if (!_data) { @@ -176,7 +170,7 @@ void MemoryObject::loadFile(char *filename) { _dataSize = s->size(); - debugC(5, kDebugLoading, "Loading %s (%d bytes)", filename, _dataSize); + debugC(5, kDebugLoading, "Loading %s (%d bytes)", filename.c_str(), _dataSize); _data = (byte *)calloc(_dataSize, 1); s->read(_data, _dataSize); @@ -205,7 +199,7 @@ byte *MemoryObject::loadData() { } void MemoryObject::freeData() { - debugC(8, kDebugMemory, "MemoryObject::freeData(): file: %s", _memfilename); + debugC(8, kDebugMemory, "MemoryObject::freeData(): file: %s", _memfilename.c_str()); if (_data) free(_data); @@ -238,9 +232,9 @@ bool MemoryObject2::load(MfcArchive &file) { _mflags |= 1; - debugC(5, kDebugLoading, "MemoryObject2::load: <%s>", _memfilename); + debugC(5, kDebugLoading, "MemoryObject2::load: <%s>", _memfilename.c_str()); - if (_memfilename && *_memfilename) { + if (!_memfilename.empty()) { MemoryObject::loadFile(_memfilename); } diff --git a/engines/fullpipe/utils.h b/engines/fullpipe/utils.h index 2f9b75c07f..d2e069a6be 100644 --- a/engines/fullpipe/utils.h +++ b/engines/fullpipe/utils.h @@ -130,7 +130,7 @@ class MemoryObject : CObject { friend class Scene; protected: - char *_memfilename; + Common::String _memfilename; int _mfield_8; int _mfield_C; int _mfield_10; @@ -145,7 +145,7 @@ class MemoryObject : CObject { virtual ~MemoryObject(); virtual bool load(MfcArchive &file); - void loadFile(char *filename); + void loadFile(Common::String filename); void load() { loadFile(_memfilename); } byte *getData(); byte *loadData(); |