From 44342619d43375313b56f7c530c4532b0f69be25 Mon Sep 17 00:00:00 2001 From: Joseph Hunkeler Date: Wed, 25 Mar 2026 13:22:42 -0400 Subject: Refactor program structure --- common.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 common.h (limited to 'common.h') 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 +#include +#include +#include + +#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 -- cgit