From dc28082a9ba55dac68883cb7b26514f921aa8edd Mon Sep 17 00:00:00 2001 From: standenboy Date: Thu, 16 May 2024 18:39:21 +0100 Subject: added a load of files --- comp/lucas-standen-NEA/code/tokenizer/util.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 comp/lucas-standen-NEA/code/tokenizer/util.c (limited to 'comp/lucas-standen-NEA/code/tokenizer/util.c') diff --git a/comp/lucas-standen-NEA/code/tokenizer/util.c b/comp/lucas-standen-NEA/code/tokenizer/util.c new file mode 100644 index 0000000..de5b6b2 --- /dev/null +++ b/comp/lucas-standen-NEA/code/tokenizer/util.c @@ -0,0 +1,27 @@ +#include +#include +#include +#include + +void Die(); // brings down the program +void *CheckedMalloc(long size); // malloc checked +void *CheckedRealloc(void *out, long size); // realloc checked + +void Die(){ + perror("zpy parser"); + exit(errno); +} + +void *CheckedMalloc(long size){ + void *out = malloc(size); + if (out == NULL) + Die(); + return out; +} + +void *CheckedRealloc(void *orig, long size){ + void *out = realloc(orig, size); + if (out == NULL) + Die(); + return out; +} -- cgit v1.2.3