This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

calloc() implementation question


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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]