Comment by ppoint

8 years ago

calloc zeroes memory on allocation.

Yes, I think the question was something like "why doesn't malloc call calloc?".

  • Always nice to have options. Not zeroing memory on allocation might save a few cpu cycles.

    • It's pretty much the definition of false economy. Would you rather save a few cycles or suffer debilitating security bugs at random intervals? Always use calloc unless a) there's a proven performance problem and b) you know for a fact that due to careful inspection/static analysis/black magic malloc is safe. Then use calloc anyway because why risk it?

      1 reply →