4 ms·
The author missed a benefit of `calloc` that it can avoid re-zeroing memory. For example if the allocator knows that it just got a fresh page from the OS (which
by kevincox 4y ago
The author missed a benefit of `calloc` that it can avoid re-zeroing memory. For example if the allocator knows that it just got a fresh page from the OS (which has already zeroed this memory for security reasons) it can avoid doing another zero. This is not only a performance improvement but can avoid touching (and forcing the OS to actually allocate) all of the pages. Maybe the best approach here would be an extra `is_zeroed` (which can be a false negative but not a false positive) field on the return from the alloc call.