3 ms·
> No measurable difference in speed, and code is much more clean. This only works with some malloc implementations. There are platforms where this will result
by nwellnhof 3y ago
> No measurable difference in speed, and code is much more clean.
This only works with some malloc implementations. There are platforms where this will result in quadratic behavior, so don't do this if you want to write portable code.
- jandrese 3y agoYeah, I was just thinking that line of thought was notorious in the past for some serious performance issues. It's one reason you sometimes see arena allocators doubling the memory every time they have to grow. Might be something to benchmark on your system before using. It's also possible those badly behaving allocators are in the past and this is fine to do now.
- kevin_thibedeau 3y agoThey're not in the past. There are systems that don't even implement realloc().