3 ms·
> new, [...] may compile down to as little as two x86 instructions Yes, but when you have a million of allocation, that still means two million instructions. m
by mariusor 5y ago
> new, [...] may compile down to as little as two x86 instructions
Yes, but when you have a million of allocation, that still means two million instructions. malloc/free allows a much easier path to allocating a large chunk of memory in which you can play around with your million structs having only the overhead of accessing pointers (and, of course, thinking about where to point them).
- kaba0 5y agoWith all due respect, that is trivial to do in C++, hell it will be actually readable and much safer than malloc(n*sizeof(something)) and then for looping over that to initialize values.