aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/fullpipe/ngiarchive.cpp18
-rw-r--r--engines/fullpipe/ngiarchive.h5
-rw-r--r--engines/fullpipe/sound.cpp2
3 files changed, 9 insertions, 16 deletions
diff --git a/engines/fullpipe/ngiarchive.cpp b/engines/fullpipe/ngiarchive.cpp
index 7d75dc2e78..e69307addd 100644
--- a/engines/fullpipe/ngiarchive.cpp
+++ b/engines/fullpipe/ngiarchive.cpp
@@ -70,7 +70,6 @@ NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename)
}
NgiHeader header;
- NgiHeader *head;
for (uint i = 0; i < count; i++) {
memcpy(header.filename, &fat[i * 32], 12);
@@ -84,9 +83,7 @@ NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename)
warning("File has flags: %.8x\n", header.flags & 0x1e0);
}
- head = new NgiHeader(header);
-
- _headers[header.filename] = head;
+ _headers[header.filename].reset(new NgiHeader(header));
}
free(fat);
@@ -98,19 +95,14 @@ NGIArchive::NGIArchive(const Common::String &filename) : _ngiFilename(filename)
NGIArchive::~NGIArchive() {
debugC(0, kDebugLoading, "NGIArchive Destructor Called");
- NgiHeadersMap::iterator it = _headers.begin();
- for ( ; it != _headers.end(); ++it) {
- delete it->_value;
- }
-
- g_fp->_currArchive = 0;
+ g_fp->_currArchive = nullptr;
}
bool NGIArchive::hasFile(const Common::String &name) const {
return _headers.contains(name);
}
- int NGIArchive::listMembers(Common::ArchiveMemberList &list) const {
+int NGIArchive::listMembers(Common::ArchiveMemberList &list) const {
int matches = 0;
NgiHeadersMap::const_iterator it = _headers.begin();
@@ -134,7 +126,7 @@ Common::SeekableReadStream *NGIArchive::createReadStreamForMember(const Common::
return 0;
}
- NgiHeader *hdr = _headers[name];
+ NgiHeader *hdr = _headers[name].get();
Common::File archiveFile;
archiveFile.open(_ngiFilename);
@@ -149,7 +141,7 @@ Common::SeekableReadStream *NGIArchive::createReadStreamForMember(const Common::
return new Common::MemoryReadStream(data, hdr->size, DisposeAfterUse::YES);
}
-Common::Archive *makeNGIArchive(const Common::String &name) {
+NGIArchive *makeNGIArchive(const Common::String &name) {
return new NGIArchive(name);
}
diff --git a/engines/fullpipe/ngiarchive.h b/engines/fullpipe/ngiarchive.h
index a5b05a2e50..18646faf00 100644
--- a/engines/fullpipe/ngiarchive.h
+++ b/engines/fullpipe/ngiarchive.h
@@ -23,6 +23,7 @@
#ifndef FULLPIPE_NGIARCHIVE_H
#define FULLPIPE_NGIARCHIVE_H
+#include "common/ptr.h"
#include "common/str.h"
namespace Fullpipe {
@@ -39,7 +40,7 @@ struct NgiHeader {
char filename[NGI_FILENAME_MAX];
};
-typedef Common::HashMap<Common::String, NgiHeader*, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> NgiHeadersMap;
+typedef Common::HashMap<Common::String, Common::ScopedPtr<NgiHeader>, Common::IgnoreCase_Hash, Common::IgnoreCase_EqualTo> NgiHeadersMap;
class NGIArchive : public Common::Archive {
NgiHeadersMap _headers;
@@ -62,7 +63,7 @@ public:
*
* May return 0 in case of a failure.
*/
-Common::Archive *makeNGIArchive(const Common::String &name);
+NGIArchive *makeNGIArchive(const Common::String &name);
} // End of namespace Fullpipe
diff --git a/engines/fullpipe/sound.cpp b/engines/fullpipe/sound.cpp
index 77112cb518..4ab6520c33 100644
--- a/engines/fullpipe/sound.cpp
+++ b/engines/fullpipe/sound.cpp
@@ -57,7 +57,7 @@ bool SoundList::load(MfcArchive &file, const Common::String &fname) {
_soundItems = (Sound **)calloc(_soundItemsCount, sizeof(Sound *));
if (!fname.empty()) {
- _libHandle = (NGIArchive *)makeNGIArchive(fname);
+ _libHandle = makeNGIArchive(fname);
} else {
_libHandle = 0;
}