Commit f1a80e85 authored by Paul Eggert's avatar Paul Eggert
Browse files

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.
parent 83e9cc89
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.
......@@ -76,14 +76,14 @@ x2realloc (void *p, size_t *pn)
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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment