2 ms·
I always use calloc when allocating many blocks at once, as you said. Yes, you get a free bzero() with it, but that's not why I use it. When I'm trying to allo
by yan 18y ago
I always use calloc when allocating many blocks at once, as you said. Yes, you get a free bzero() with it, but that's not why I use it.
When I'm trying to allocate memory for many blocks of something, I'd use calloc just because it makes my intentions clearer in the code when someone else is reading it. If I'm allocating memory just for one area or block, I'd use malloc+bzero or possibly calloc with a clear block count of one. The efficiency in the end is pretty equivalent but it makes your code easier to digest to other people.