Hacker News
new
|
past
|
comments
|
ask
|
show
|
jobs
|
submit
login
AlexeyBrin
on Jan 7, 2017
|
parent
|
context
|
favorite
| on:
C99/C11 dynamic array that mimics C++'s std::vecto...
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
on Jan 7, 2017
|
next
[–]
PS 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
on Jan 7, 2017
|
parent
|
next
[–]
Correct, this is a bug.
calloc
will better mimic the way C++ std::vector works.
antirez
on Jan 7, 2017
|
prev
[–]
Oh... thanks! I was not aware.
Guidelines
|
FAQ
|
Lists
|
API
|
Security
|
Legal
|
Apply to YC
|
Contact
Search: