Hacker News new | ask | show | jobs
by bcpermafrost 3484 days ago
It is not as you say.

The article suggests that Malloc + Memset is slower than Calloc.

Malloc will be faster depending on your use case. If your plan is to eventually call memset. Then just use Calloc, otherwise malloc will be faster all the time.

1 comments

n00b question: Why would you not memset? I would assume you'd want to start with all zeroed memory in almost all cases.
Not always, you could be planning on filling the data with something else. Very common to do that.
I.e.: reading from a file or copying memory?