summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2024-02-17 23:49:27 +0100
committerCarl Hetherington <cth@carlh.net>2024-02-17 23:49:27 +0100
commitc27aa600966b2a8f9d9ff9efd545f5866244d195 (patch)
tree303c5407329c83d16e031c5d3f8e4bc7c04158c1 /src
parent24fb1bb38b04869a37a34e51e6e9548768b0d39f (diff)
Cleanup: use std::vector rather than a raw array.
Diffstat (limited to 'src')
-rw-r--r--src/util.cc9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/util.cc b/src/util.cc
index a030ecb0..f5a15944 100644
--- a/src/util.cc
+++ b/src/util.cc
@@ -265,14 +265,13 @@ dcp::file_to_string (boost::filesystem::path p, uintmax_t max_length)
throw FileError ("could not open file", p, errno);
}
- char* c = new char[len];
+ std::vector<char> buffer(len);
/* This may read less than `len' if we are on Windows and we have CRLF in the file */
- int const N = f.read(c, 1, len);
+ int const N = f.read(buffer.data(), 1, len);
+ return string(buffer.data(), N);
+}
- string s (c, N);
- delete[] c;
- return s;
}