diff options
| author | Carl Hetherington <cth@carlh.net> | 2021-10-11 19:55:06 +0200 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-05-02 00:22:43 +0200 |
| commit | 809bcfd85fad2ef7d4131c054be4cccd5bcc9d05 (patch) | |
| tree | 8170cee031af2209afa1905b8703f77b6d748d8e /src/lib/file_log.cc | |
| parent | 9a9ce1aec97db89b00bc216edf7cee5f3d48670e (diff) | |
Replace some raw arrays with std::vectors.
Diffstat (limited to 'src/lib/file_log.cc')
| -rw-r--r-- | src/lib/file_log.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/lib/file_log.cc b/src/lib/file_log.cc index 4d6a0e6ea..a9522bad5 100644 --- a/src/lib/file_log.cc +++ b/src/lib/file_log.cc @@ -87,23 +87,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; |
