aboutsummaryrefslogtreecommitdiffstats
path: root/util.h
diff options
context:
space:
mode:
Diffstat (limited to 'util.h')
-rw-r--r--util.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/util.h b/util.h
index 501d11e..052a106 100644
--- a/util.h
+++ b/util.h
@@ -2,5 +2,14 @@
#define min(a, b) ((a < b) ? a : b)
#define max(a, b) ((a > b) ? a : b)
+#define expect(x) do { \
+ if (!(x)) { \
+ fprintf(stderr, "Fatal error: %s:%d: assertion '%s' failed\n", \
+ __FILE__, __LINE__, #x); \
+ abort(); \
+ } \
+ } while (0)
+
+
void free_arr(void **arr, int n);
int lsearch(const void *key, const void *base, size_t n, size_t size, int (*cmp)(const void *keyval, const void *datum));