aboutsummaryrefslogtreecommitdiff
path: root/src/common.c
diff options
context:
space:
mode:
authorkartofen <mladenovnasko0@gmail.com>2023-08-14 21:20:39 +0300
committerkartofen <mladenovnasko0@gmail.com>2023-08-14 21:20:39 +0300
commita7bb8ace49f5725e0f92336ab5af28b4c8900aff (patch)
tree5d00d7a5d159e9702b46c23542fffc09e591c271 /src/common.c
parentf83187a830deff27ce0cdd4c175ffe2785461685 (diff)
parser done
Diffstat (limited to 'src/common.c')
-rw-r--r--src/common.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/common.c b/src/common.c
new file mode 100644
index 0000000..084c584
--- /dev/null
+++ b/src/common.c
@@ -0,0 +1,33 @@
+#include <string.h>
+#include <errno.h>
+#include "common.h"
+
+void *xmalloc(size_t size)
+{
+ void *ret;
+ if(!(ret = malloc(size))) {
+ die("malloc: %s", strerror(errno));
+ }
+
+ return ret;
+}
+
+void *xcalloc(size_t nmemb, size_t size)
+{
+ void *ret;
+ if(!(ret = calloc(nmemb, size))) {
+ die("calloc: %s", strerror(errno));
+ }
+
+ return ret;
+}
+
+void *xrealloc(void *ptr, size_t size)
+{
+ void *ret;
+ if(!(ret = realloc(ptr, size))) {
+ die("realloc: %s", strerror(errno));
+ }
+
+ return ret;
+}