3 ms·
It is fairly easy to develop software in such a way that the correctly initialized version of most structures is mostly zero. If you get in the habit of designi
by nhaehnle 11y ago
It is fairly easy to develop software in such a way that the correctly initialized version of most structures is mostly zero. If you get in the habit of designing your code that way, calloc is clearly superior: you get much faster initialization of your structures (because of SSE or equivalent optimizations for memset) and your code is more maintainable (because extending a structure with a field where a zero value implies unchanged behaviour will just work without changing all the places where the structure is initialized).