tuse libc calloc() and show 'calloc:' on error - sacc - sacc (saccomys): simple gopher client.
DIR Log
DIR Files
DIR Refs
DIR LICENSE
---
DIR commit e1eceee39ab489e5bc8ead2f8244b0cad3d1618f
DIR parent 687f65e4cda6fdfe5eafd263bb30a091fe3443af
HTML Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date: Sun, 25 Feb 2018 15:53:29 +0100
use libc calloc() and show 'calloc:' on error
Diffstat:
sacc.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
---
DIR diff --git a/sacc.c b/sacc.c
t@@ -121,10 +121,10 @@ xmalloc(const size_t n)
static void *
xcalloc(size_t n)
{
- char *m = xmalloc(n);
+ char *m = calloc(1, n);
- while (n)
- m[--n] = 0;
+ if (!m)
+ die("calloc: %s", strerror(errno));
return m;
}