4 ms·
This mimics C++ vector, e.g.: vector<int> vec(5); vec.push_back(11); vec.push_back(12); Now you have in vec: 0, 0, 0, 0, 0, 11, 12 But your
by AlexeyBrin 10y ago
This mimics C++ vector, e.g.:
vector<int> vec(5);
vec.push_back(11);
vec.push_back(12);
Now you have in vec:
0, 0, 0, 0, 0, 11, 12
But your suggestion is better from an API point of view.
- antirez 10y agoOh... thanks! I was not aware.
- antirez 10y agoPS please note that there is no memset nor any other mean to zero initialize the elements. So the code appears to have a bug anyway.
- AlexeyBrin 10y agoCorrect, this is a bug. calloc will better mimic the way C++ std::vector works.