* lib/xmalloc.c (xzalloc): Use xcalloc rather than xmalloc+memset,
because when the memory is freshly allocated from the OS via sbrk
or mmap, calloc can avoid doing the memset.
2019-12-17 Paul Eggert <eggert@cs.ucla.edu>
+ xalloc: tune xzalloc for fresh allocations
+ * lib/xmalloc.c (xzalloc): Use xcalloc rather than xmalloc+memset,
+ because when the memory is freshly allocated from the OS via sbrk
+ or mmap, calloc can avoid doing the memset.
+
dfa: new function dfacopysyntax
* lib/dfa.c (struct dfa): Move syntax member later so
that dfacopysyntax can easily clear earlier members.
return x2nrealloc (p, pn, 1);
}
-/* Allocate S bytes of zeroed memory dynamically, with error checking.
+/* Allocate N bytes of zeroed memory dynamically, with error checking.
There's no need for xnzalloc (N, S), since it would be equivalent
to xcalloc (N, S). */
void *
-xzalloc (size_t s)
+xzalloc (size_t n)
{
- return memset (xmalloc (s), 0, s);
+ return xcalloc (n, 1);
}
/* Allocate zeroed memory for N elements of S bytes, with error