summaryrefslogtreecommitdiff
path: root/comp/lucas-standen-NEA/code/tokenizer/util.c
diff options
context:
space:
mode:
authorstandenboy <standenboy@seacrossedlovers.xyz>2024-05-16 18:39:21 +0100
committerstandenboy <standenboy@seacrossedlovers.xyz>2024-05-16 18:39:21 +0100
commitdc28082a9ba55dac68883cb7b26514f921aa8edd (patch)
tree563c3b1c3f177f79e7e301b079b1d56f5904c384 /comp/lucas-standen-NEA/code/tokenizer/util.c
parent14b5defaa1a106afd51e3c64f6791e1ed081feea (diff)
added a load of files
Diffstat (limited to 'comp/lucas-standen-NEA/code/tokenizer/util.c')
-rw-r--r--comp/lucas-standen-NEA/code/tokenizer/util.c27
1 files changed, 27 insertions, 0 deletions
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 <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <error.h>
+
+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;
+}