calloc(3) tells libc upfront that the memory needs to be zeroed rather
than giving it the news later with memset. Perhaps this allows it to
allocate from a CoW page of zero bytes, or it benefits from some other
way in memset not having to clear each bit, but it knocks about 15% off
the wall-clock time and the number of library calls under ltrace(1).
NEW(vec);
bytes = BVEC_BYTES (vec, init_size ? init_size : VEC_INIT_SIZE);
NEW(vec);
bytes = BVEC_BYTES (vec, init_size ? init_size : VEC_INIT_SIZE);
- vec->bits = mh_xmalloc (bytes);
- memset (vec->bits, 0, bytes);
+ vec->bits = mh_xcalloc (1, bytes);
vec->maxsize = bytes * Nbby;
return vec;
vec->maxsize = bytes * Nbby;
return vec;
NEW(vec);
vec->maxsize = init_size ? init_size : VEC_INIT_SIZE;
bytes = vec->maxsize * sizeof (char *);
NEW(vec);
vec->maxsize = init_size ? init_size : VEC_INIT_SIZE;
bytes = vec->maxsize * sizeof (char *);
- vec->strs = mh_xmalloc (bytes);
- memset (vec->strs, 0, bytes);
+ vec->strs = mh_xcalloc (1, bytes);
vec->size = 0;
return vec;
vec->size = 0;
return vec;
NEW(vec);
vec->maxsize = init_size ? init_size : VEC_INIT_SIZE;
bytes = vec->maxsize * sizeof (int);
NEW(vec);
vec->maxsize = init_size ? init_size : VEC_INIT_SIZE;
bytes = vec->maxsize * sizeof (int);
- vec->ints = mh_xmalloc (bytes);
- memset (vec->ints, 0, bytes);
+ vec->ints = mh_xcalloc (1, bytes);
vec->size = 0;
return vec;
vec->size = 0;
return vec;