summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2016-02-22 17:50:15 +0100
committerMax Kellermann <max@duempel.org>2016-02-22 17:50:15 +0100
commit1f5b9c618577ea1424ac83c4cac37231d334382d (patch)
tree9e74b6b54ca8be0e2524f450d780bdcadddd354e /src
parenta5f8fd774d91c0e632ef87e596507b86cd142aec (diff)
tag/ApeLoader: use std::unique_ptr
Diffstat (limited to 'src')
-rw-r--r--src/tag/ApeLoader.cxx11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/tag/ApeLoader.cxx b/src/tag/ApeLoader.cxx
index 26d42c48b..3488230a7 100644
--- a/src/tag/ApeLoader.cxx
+++ b/src/tag/ApeLoader.cxx
@@ -28,6 +28,8 @@
#include "util/StringView.hxx"
#include "util/Error.hxx"
+#include <memory>
+
#include <stdint.h>
#include <assert.h>
#include <string.h>
@@ -69,15 +71,13 @@ tag_ape_scan(InputStream &is, ApeTagCallback callback)
remaining -= sizeof(footer);
assert(remaining > 10);
- char *buffer = new char[remaining];
- if (!is.ReadFull(buffer, remaining, IgnoreError())) {
- delete[] buffer;
+ std::unique_ptr<char[]> buffer(new char[remaining]);
+ if (!is.ReadFull(buffer.get(), remaining, IgnoreError()))
return false;
- }
/* read tags */
unsigned n = FromLE32(footer.count);
- const char *p = buffer;
+ const char *p = buffer.get();
while (n-- && remaining > 10) {
size_t size = FromLE32(*(const uint32_t *)p);
p += 4;
@@ -106,7 +106,6 @@ tag_ape_scan(InputStream &is, ApeTagCallback callback)
remaining -= size;
}
- delete[] buffer;
return true;
}