Skip to content
Snippets Groups Projects
Commit bfd35a88 authored by Hahn, Steven's avatar Hahn, Steven
Browse files

use std::vector for variable length array.

parent a68d7b46
No related branches found
No related tags found
No related merge requests found
...@@ -30,7 +30,7 @@ struct DasEvent { ...@@ -30,7 +30,7 @@ struct DasEvent {
/** Creates a dummy file with so many bytes */ /** Creates a dummy file with so many bytes */
static void MakeDummyFile(std::string filename, size_t num_bytes) { static void MakeDummyFile(std::string filename, size_t num_bytes) {
char buffer[num_bytes]; std::vector<char> buffer(num_bytes);
for (size_t i = 0; i < num_bytes; i++) { for (size_t i = 0; i < num_bytes; i++) {
// Put 1,2,3 in 32-bit ints // Put 1,2,3 in 32-bit ints
if (i % 4 == 0) if (i % 4 == 0)
...@@ -40,7 +40,7 @@ static void MakeDummyFile(std::string filename, size_t num_bytes) { ...@@ -40,7 +40,7 @@ static void MakeDummyFile(std::string filename, size_t num_bytes) {
} }
std::ofstream myFile(filename.c_str(), std::ios::out | std::ios::binary); std::ofstream myFile(filename.c_str(), std::ios::out | std::ios::binary);
myFile.write(buffer, num_bytes); myFile.write(buffer.data(), num_bytes);
myFile.close(); myFile.close();
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment