From d1fc03d6758dcb7ccca3e4255114d85acfad08d4 Mon Sep 17 00:00:00 2001 From: Malfurious Date: Fri, 7 Jul 2023 19:30:39 -0400 Subject: Add malloc wrapper Abort on allocation failure. This is mostly done as a formality, as Linux tends to over-commit memory anyway. In the event of most failures, we won't have a reasonable recovery either. Signed-off-by: Malfurious --- helpers.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'helpers.c') diff --git a/helpers.c b/helpers.c index c93b774..2cd119d 100644 --- a/helpers.c +++ b/helpers.c @@ -1,8 +1,16 @@ +#include #include #include +#include #include "helpers.h" +void *xmalloc(size_t size) { + void *ptr = malloc((size ? size : 1)); + assert(ptr != NULL); + return ptr; +} + void cursinit(void) { setlocale(LC_ALL, ""); initscr(); -- cgit v1.2.3