diff --git a/src/common/mempattern.c b/src/common/mempattern.c
index acf6eac2f571c5c66ddcf3a384dec563b25a28ff..df9e1b93a5f638497abee808a2e32b22b88822fd 100644
--- a/src/common/mempattern.c
+++ b/src/common/mempattern.c
@@ -21,8 +21,30 @@
 #include <config.h>
 #include <stdarg.h>
 
+#include "common/log.h"
 #include "common/slab/alloc-common.h"
 
+void* xmalloc(size_t l)
+{
+	void *p = malloc(l);
+	if (p == NULL) {
+		log_server_fatal("Failed to allocate %zu bytes.\n", l);
+		abort();
+	}
+	return p;
+}
+
+void *xrealloc(void *p, size_t l)
+{
+	p = realloc(p, l);
+	if (p == NULL) {
+		log_server_fatal("Failed to reallocate to %zu bytes from %p.\n",
+		                 l, p);
+		abort();
+	}
+	return p;
+}
+
 
 int mreserve(char **p, size_t tlen, size_t min, size_t allow, size_t *reserved)
 {
diff --git a/src/common/mempattern.h b/src/common/mempattern.h
index ebfe4aeb031574a21461064234d924918853897e..cd19cf241d5c9396d4dad3af8b5369787938f787 100644
--- a/src/common/mempattern.h
+++ b/src/common/mempattern.h
@@ -27,6 +27,12 @@
 #ifndef _KNOTD_COMMON_MALLOC_H_
 #define _KNOTD_COMMON_MALLOC_H_
 
+/*! \brief Allocate memory or die. */
+void* xmalloc(size_t l);
+
+/*! \brief Reallocate memory or die. */
+void *xrealloc(void *p, size_t l);
+
 /*!
  * \brief Reserve new or trim excessive memory.
  *