calloc() implementation question
Olivier Langlois
olivier@trillion01.com
Thu Dec 12 13:29:00 GMT 2013
Hi,
Just by inspecting the code, there is something that I do not find
obvious.
nclears variable values distribution must have been analyzed and
everything must have been carefully balanced
if nclears is often <= 9 is it better to evaluate nclears up to 4 times
rather than unconditionally use memset() for any value of nclears?
if (nclears > 9)
MALLOC_ZERO(d, clearsize);
else {
*(d+0) = 0;
*(d+1) = 0;
*(d+2) = 0;
if (nclears > 4) {
*(d+3) = 0;
*(d+4) = 0;
if (nclears > 6) {
*(d+5) = 0;
*(d+6) = 0;
if (nclears > 8) {
*(d+7) = 0;
*(d+8) = 0;
}
}
}
}
Greetings,
Olivier
More information about the Libc-alpha
mailing list