summaryrefslogtreecommitdiff
path: root/src/lib/file_log.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2021-10-11 19:55:06 +0200
committerCarl Hetherington <cth@carlh.net>2021-10-11 20:13:21 +0200
commit44b69f2d9affb048c3d166e3a62bf3462dd5c8b5 (patch)
tree7cf2a540d01c66f9a7d12acfdabd0ee2f4251c80 /src/lib/file_log.cc
parent805d4a48fa6e4d8e28fd582a2ae6ba78b8343144 (diff)
Replace some raw arrays with std::vectors.
Diffstat (limited to 'src/lib/file_log.cc')
-rw-r--r--src/lib/file_log.cc11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib/file_log.cc b/src/lib/file_log.cc
index 5cc9c5569..246641cc9 100644
--- a/src/lib/file_log.cc
+++ b/src/lib/file_log.cc
@@ -83,23 +83,22 @@ FileLog::head_and_tail (int amount) const
string out;
- auto buffer = new char[max(head_amount, tail_amount) + 1];
+ std::vector<char> buffer(max(head_amount, tail_amount) + 1);
- int N = fread (buffer, 1, head_amount, f);
+ int N = fread (buffer.data(), 1, head_amount, f);
buffer[N] = '\0';
- out += string (buffer);
+ out += string (buffer.data());
if (tail_amount > 0) {
out += "\n .\n .\n .\n";
fseek (f, - tail_amount - 1, SEEK_END);
- N = fread (buffer, 1, tail_amount, f);
+ N = fread (buffer.data(), 1, tail_amount, f);
buffer[N] = '\0';
- out += string (buffer) + "\n";
+ out += string (buffer.data()) + "\n";
}
- delete[] buffer;
fclose (f);
return out;