diff options
author | Malfurious <m@lfurio.us> | 2023-07-07 19:30:39 -0400 |
---|---|---|
committer | Malfurious <m@lfurio.us> | 2023-07-07 19:30:39 -0400 |
commit | d1fc03d6758dcb7ccca3e4255114d85acfad08d4 (patch) | |
tree | fe756d0f92957bc426bddf450c682ab5a65c3ede | |
parent | d622a30a82f8ac6914926a5bfdc0e31dff6ce55d (diff) | |
download | misplays-d1fc03d6758dcb7ccca3e4255114d85acfad08d4.tar.gz misplays-d1fc03d6758dcb7ccca3e4255114d85acfad08d4.zip |
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 <m@lfurio.us>
-rw-r--r-- | helpers.c | 8 | ||||
-rw-r--r-- | helpers.h | 3 |
2 files changed, 11 insertions, 0 deletions
@@ -1,8 +1,16 @@ +#include <assert.h> #include <locale.h> #include <stdarg.h> +#include <stdlib.h> #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(); @@ -2,6 +2,9 @@ #include <ncurses.h> #include <panel.h> +#include <stddef.h> + +extern void *xmalloc(size_t size); extern void cursinit(void); extern void cursupdate(void); |