about summary refs log tree commit diff
path: root/src/libutil/util.cc
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2017-01-16T21·24+0100
committerEelco Dolstra <edolstra@gmail.com>2017-01-16T21·24+0100
commit2b9d0a99cbf7649c20492bc539e2823a2d2e57c5 (patch)
treebdf06b8448c4f8b619383bda5284e7b4ee1219d6 /src/libutil/util.cc
parent40dfac968a87c1d90b5b3c9e3ffe72a370165047 (diff)
AutoDeleteArray -> std::unique_ptr
Also, switch to C++14 for std::make_unique.
Diffstat (limited to 'src/libutil/util.cc')
-rw-r--r--src/libutil/util.cc7
1 files changed, 3 insertions, 4 deletions
diff --git a/src/libutil/util.cc b/src/libutil/util.cc
index ce16cc30a5c7..0e1849df09ea 100644
--- a/src/libutil/util.cc
+++ b/src/libutil/util.cc
@@ -272,11 +272,10 @@ string readFile(int fd)
     if (fstat(fd, &st) == -1)
         throw SysError("statting file");
 
-    unsigned char * buf = new unsigned char[st.st_size];
-    AutoDeleteArray<unsigned char> d(buf);
-    readFull(fd, buf, st.st_size);
+    auto buf = std::make_unique<unsigned char[]>(st.st_size);
+    readFull(fd, buf.get(), st.st_size);
 
-    return string((char *) buf, st.st_size);
+    return string((char *) buf.get(), st.st_size);
 }