commit 35443f3160929f8ab9caf65c7dd3ee25591e2f92
parent 226c3a9adbbc047f7820b91412bdbb6cf546e8fe
Author: William Djupström <william@deepztream.com>
Date: Sun, 4 Oct 2026 18:53:02 +0200
Add `todo_r` and fix asserts
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/dlib.h b/dlib.h
@@ -20,6 +20,12 @@
abort(); \
} while (0)
+#define todo_r(msg, ret) \
+ do { \
+ fprintf(stderr, "%s:%i:1: Error: TODO: %s\n", __FILE__, __LINE__, (msg)); \
+ return (ret); \
+ } while (0)
+
#define todo(msg) \
do { \
fprintf(stderr, "%s:%i:1: Error: TODO: %s\n", __FILE__, __LINE__, (msg)); \
@@ -75,13 +81,13 @@
#define da_delete(da, index)\
do {\
- assert(index >= 0 && index < (da)->count);\
+ assert((size_t) index < (size_t) (da)->count);\
(da)->items[index] = (da)->items[--(da)->count];\
} while (0)
#define da_delete_ordered(da, index)\
do {\
- assert(index < (da)->count);\
+ assert((size_t) index < (size_t) (da)->count);\
memmove(&(da)->items[(index)], &(da)->items[(index) + 1], sizeof(*(da)->items) * ((da)->count-- - (index) - 1));\
} while (0)