summaryrefslogtreecommitdiff
path: root/xmalloc.h
diff options
context:
space:
mode:
authorTobias Klauser <tklauser@distanz.ch>2014-06-24 19:06:05 +0200
committerTobias Klauser <tklauser@distanz.ch>2014-06-25 10:18:09 +0200
commit46b0ace509d9ed013915e9ab8013c7c712e11395 (patch)
treea2882741a458995c1d3303bf87e6c88ea17724a2 /xmalloc.h
parent6424dd90f721fd968c1159236f525ed59f355045 (diff)
xmalloc: Add and use xcalloc
Add a wrapper for calloc which checks for integer overflows in the calculation of the size to allocate. Use xcalloc to allocate an array of objects instead of calculating the size ourselves, which might cause an integer overflow. Signed-off-by: Tobias Klauser <tklauser@distanz.ch>
Diffstat (limited to 'xmalloc.h')
-rw-r--r--xmalloc.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/xmalloc.h b/xmalloc.h
index 952b827..2ad0372 100644
--- a/xmalloc.h
+++ b/xmalloc.h
@@ -7,6 +7,7 @@
#include "die.h"
extern void *xmalloc(size_t size) __hidden;
+extern void *xcalloc(size_t nmemb, size_t size) __hidden;
extern void *xzmalloc(size_t size) __hidden;
extern void *xmallocz(size_t size) __hidden;
extern void *xmalloc_aligned(size_t size, size_t alignment) __hidden;