4 ms·
> Only if your libc implements calloc as malloc+memset would this be a problem. Does glibc do that? OK, it's not guaranteed that it will be, but the source sho
by alexkus 14y ago
> Only if your libc implements calloc as malloc+memset would this be a problem. Does glibc do that?
OK, it's not guaranteed that it will be, but the source shows several code paths where memset can be called during calloc():-
http://sourceware.org/git/?p=glibc.git;a=blob_plain;f=malloc/malloc.c;hb=HEAD http://sourceware.org/git/?p=glibc.git;a=blob_plain;f=malloc...
My quick experiement with 32-bit libc-2.13 showed that using calloc() is significantly slower than using malloc().
[EDIT] Should have read pedrocr's response fully.