Skip to content

Commit

Permalink
push_back for preallocation, avoid possible out of bounds crash, closes
Browse files Browse the repository at this point in the history
  • Loading branch information
seanpquinn authored Nov 4, 2023
1 parent c588728 commit 22aea8f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion test/kvec_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ int main()
for (i = 0; i < M; ++i) {
std::vector<int> array;
array.reserve(N);
for (j = 0; j < N; ++j) array[j] = j;
for (j = 0; j < N; ++j) array.push_back(j);
}
printf("C++ vector, preallocated: %.3f sec\n",
(float)(clock() - t) / CLOCKS_PER_SEC);
Expand Down

0 comments on commit 22aea8f

Please sign in to comment.