summaryrefslogtreecommitdiff
path: root/src/lib.c
diff options
context:
space:
mode:
authorFreya Murphy <freya@freyacat.org>2023-12-17 11:10:04 -0500
committerFreya Murphy <freya@freyacat.org>2023-12-17 11:10:04 -0500
commite0eacfa9773c83850ed5169d1e889ff845180581 (patch)
tree9f8bb433404ce7e4dda1b86ca4dd5d5a2fba10e9 /src/lib.c
parentsnbt (diff)
downloadnbtvis-main.tar.gz
nbtvis-main.tar.bz2
nbtvis-main.zip
refactorHEADmain
Diffstat (limited to 'src/lib.c')
-rw-r--r--src/lib.c51
1 files changed, 0 insertions, 51 deletions
diff --git a/src/lib.c b/src/lib.c
deleted file mode 100644
index e6e691a..0000000
--- a/src/lib.c
+++ /dev/null
@@ -1,51 +0,0 @@
-#include "lib.h"
-
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-__attribute__((__noreturn__))
-static void die() {
- exit(1);
-}
-
-void error_and_die(char *format, ...) {
- va_list list;
- va_start(list, format);
-
- vfprintf(stderr, format, list);
-
- die();
-}
-
-__attribute__((__noreturn__, format(printf, 1, 2)))
-void perror_and_die(char *format, ...) {
- va_list list;
- va_start(list, format);
-
- vfprintf(stderr, format, list);
- perror(": ");
-
- die();
-}
-
-void *xalloc(size_t amount) {
- void *res = malloc(amount);
- if (res == NULL)
- error_and_die("failed to allocate memory");
- return res;
-}
-
-void *xzalloc(size_t amount) {
- void *res = xalloc(amount);
- memset(res, 0, sizeof(amount));
- return res;
-}
-
-void *xrealloc(void *ptr, size_t amount) {
- void *res = realloc(ptr, amount);
- if (res == NULL)
- error_and_die("failed to allocate memory");
- return res;
-}