# define xcalloc strace_calloc
# define xmalloc strace_malloc
+/** Allocate memory, die if the allocation has failed. */
+void *xmalloc(size_t size) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((1));
+
+/**
+ * Allocate an array and zero it out (similar to calloc), die if the allocation
+ * has failed or if the product of nmemb and size is too big.
+ */
void *xcalloc(size_t nmemb, size_t size)
ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((1, 2));
-void *xmalloc(size_t size) ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((1));
+
+/** Wrapper for xcalloc(1, size) with xmalloc-like interface. */
+ATTRIBUTE_MALLOC ATTRIBUTE_ALLOC_SIZE((1))
+static inline void *
+xzalloc(size_t size)
+{
+ return xcalloc(1, size);
+}
+
+/**
+ * Reallocate memory for the array, die if the allocation has failed or
+ * if the product of nmemb and size is too big.
+ */
void *xreallocarray(void *ptr, size_t nmemb, size_t size)
ATTRIBUTE_ALLOC_SIZE((2, 3));