From what I know, calloc() should initialize all bytes to zero in the allocated memory.
This is partly true based on my understanding of the calloc
call.
It reserves the space but doesn't initialise all memory to zero. It will often or generally initialise one section to zero, and point all others to that; when memory is then modified or accessed within this block, it will initialise it to zero before using. It means that a calloc
call of very large size doesn't set all of that memory to zero multiple times, but only when it actually needs to.
tl;dr: it's an OS theory trick where kernels will cheat. There's a longer description here: https://stackoverflow.com/a/2688522/2441252.