From c27aa600966b2a8f9d9ff9efd545f5866244d195 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 17 Feb 2024 23:49:27 +0100 Subject: Cleanup: use std::vector rather than a raw array. --- src/util.cc | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src') 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 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; } -- cgit v1.2.3