attractivechaos / klib

A standalone and lightweight C library

Home Page:http://attractivechaos.github.io/klib/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Potential crash: std::vector::resize and std::vector::reserve

Fr3ya opened this issue · comments

commented

This issue lies in the test/kvec_test.cc line 57

The function of resize() and reserve() is a little similar, but reserve() only gives to enough room so that future call that leads to increase of the size (e.g. calling push_back()) will be more efficient. So maybe line57 as follows is better:
for (j = 0; j < N; ++j) array.push_back(j);