aboutsummaryrefslogtreecommitdiffstats
path: root/helpers/testdfa.c
diff options
context:
space:
mode:
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