Replace some raw arrays with std::vectors.
[dcpomatic.git] / src / lib / file_log.cc
index 4d6a0e6ea39fd67b7b13ea40fc7a7f475a227826..a9522bad507dc722033074c9a5abd45c7770dcf5 100644 (file)
@@ -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;