Signed-off-by: Nikola Pajkovsky <npajkovs(a)redhat.com>
---
inc/xfuncs.h | 1 +
lib/utils/xfuncs.c | 8 ++++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/inc/xfuncs.h b/inc/xfuncs.h
index 0be1f80..2028456 100644
--- a/inc/xfuncs.h
+++ b/inc/xfuncs.h
@@ -33,6 +33,7 @@ int ndelay_on(int fd);
int ndelay_off(int fd);
int close_on_exec_on(int fd);
+void* xcalloc(size_t nmemb, size_t size);
void* xmalloc(size_t size);
void* xrealloc(void *ptr, size_t size);
void* xzalloc(size_t size);
diff --git a/lib/utils/xfuncs.c b/lib/utils/xfuncs.c
index 7179637..214ce42 100644
--- a/lib/utils/xfuncs.c
+++ b/lib/utils/xfuncs.c
@@ -39,6 +39,14 @@ int close_on_exec_on(int fd)
return fcntl(fd, F_SETFD, FD_CLOEXEC);
}
+void *xcalloc(size_t nmemb, size_t size)
+{
+ void *ptr = calloc(nmemb, size);
+ if (!ptr && nmemb && size)
+ die_out_of_memory();
+ return ptr;
+}
+
// Die if we can't allocate size bytes of memory.
void* xmalloc(size_t size)
{
--
1.7.1