aboutsummaryrefslogtreecommitdiffstats
path: root/helpers/testdfa.c
diff options
context:
space:
mode:
authorAndrew J. Schorr <aschorr@telemetry-investments.com>2017-06-25 23:20:54 -0400
committerAndrew J. Schorr <aschorr@telemetry-investments.com>2017-06-25 23:20:54 -0400
commitc07e72504d045f8e5070668e61fa5d8a3290ab66 (patch)
tree27881767587e12327c16d39ef3cce5915e90b1c6 /helpers/testdfa.c
parent44e29458a6355ad64e8d89676a441b224ce76cbc (diff)
downloadegawk-c07e72504d045f8e5070668e61fa5d8a3290ab66.tar.gz
egawk-c07e72504d045f8e5070668e61fa5d8a3290ab66.tar.bz2
egawk-c07e72504d045f8e5070668e61fa5d8a3290ab66.zip
Remove xmalloc from gawkmisc.c, and improve dfa xalloc by using calloc instead of malloc+memset.
Diffstat (limited to 'helpers/testdfa.c')
-rw-r--r--helpers/testdfa.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/helpers/testdfa.c b/helpers/testdfa.c
index 72b97907..f61d4e26 100644
--- a/helpers/testdfa.c
+++ b/helpers/testdfa.c
@@ -880,8 +880,13 @@ xnmalloc (size_t n, size_t s)
void *
xcalloc(size_t nmemb, size_t size)
{
- void *p = xmalloc (nmemb * size);
- memset(p, '\0', nmemb * size);
+ void *p = calloc (nmemb, size);
+
+ if (p == NULL) {
+ fprintf(stderr, "xcalloc: calloc failed: %s\n", strerror(errno));
+ exit(EXIT_FAILURE);
+ }
+
return p;
}
@@ -1031,7 +1036,7 @@ xcharalloc (size_t n)
void *
xzalloc (size_t s)
{
- return memset (xmalloc (s), 0, s);
+ return xcalloc (1, s);
}
# endif