aboutsummaryrefslogtreecommitdiff
path: root/common.h
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2026-03-25 13:22:42 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2026-03-25 13:22:42 -0400
commit44342619d43375313b56f7c530c4532b0f69be25 (patch)
treecbb68df916001a3b6c3ea17eeea40e28cdc8f307 /common.h
parentd79588bdf85b8c1514019e679c7eefbc9014edd9 (diff)
downloaddo-44342619d43375313b56f7c530c4532b0f69be25.tar.gz
Refactor program structure
Diffstat (limited to 'common.h')
-rw-r--r--common.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/common.h b/common.h
new file mode 100644
index 0000000..b8c38e0
--- /dev/null
+++ b/common.h
@@ -0,0 +1,27 @@
+#ifndef DO_COMMON_H
+#define DO_COMMON_H
+
+#include <stdlib.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "str.h"
+#include "target.h"
+#include "targetlist.h"
+
+#define safe_free(PTR) { \
+ do { \
+ free((PTR)); \
+ (PTR) = NULL; \
+ } while (0); \
+}
+
+#define safe_free_array(PTR, LEN) { \
+ do { \
+ for (size_t p = 0; p < (LEN); p++) { free((PTR)[p]); } \
+ free((PTR)); \
+ } while (0); \
+}
+
+#endif //DO_COMMON_H \ No newline at end of file