aboutsummaryrefslogtreecommitdiff
path: root/src/frontend/qt_sdl/ArchiveUtil.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/frontend/qt_sdl/ArchiveUtil.cpp')
-rw-r--r--src/frontend/qt_sdl/ArchiveUtil.cpp7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/frontend/qt_sdl/ArchiveUtil.cpp b/src/frontend/qt_sdl/ArchiveUtil.cpp
index 7d1eca9..aa508e8 100644
--- a/src/frontend/qt_sdl/ArchiveUtil.cpp
+++ b/src/frontend/qt_sdl/ArchiveUtil.cpp
@@ -120,13 +120,12 @@ QVector<QString> ExtractFileFromArchive(QString path, QString wantedFile, QByteA
}
-s32 ExtractFileFromArchive(QString path, QString wantedFile, u8** filedata, u32* filesize)
+s32 ExtractFileFromArchive(QString path, QString wantedFile, std::unique_ptr<u8[]>& filedata, u32* filesize)
{
struct archive *a = archive_read_new();
struct archive_entry *entry;
int r;
- if (!filedata) return -1;
archive_read_support_format_all(a);
archive_read_support_filter_all(a);
@@ -148,8 +147,8 @@ s32 ExtractFileFromArchive(QString path, QString wantedFile, u8** filedata, u32*
size_t bytesToRead = archive_entry_size(entry);
if (filesize) *filesize = bytesToRead;
- *filedata = new u8[bytesToRead];
- ssize_t bytesRead = archive_read_data(a, *filedata, bytesToRead);
+ filedata = std::make_unique<u8[]>(bytesToRead);
+ ssize_t bytesRead = archive_read_data(a, filedata.get(), bytesToRead);
archive_read_close(a);
archive_read_free(a);