Commit c58e98d6 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

Add a miniobj macro for taking over pointer

There's a recurring pattern throughout the code base of taking over
a reference (by nulling the original) essentially when resources are
freed. Instead of repeating this anti dangling pointers measure, it
can be wrapped in a documenting utility macro.
parent 34d0fe4a
......@@ -52,6 +52,14 @@
CHECK_OBJ((to), (type_magic)); \
} while (0)
#define TAKE_OBJ_NOTNULL(to, pfrom, type_magic) \
do { \
assert((pfrom) != NULL); \
(to) = *(pfrom); \
*(pfrom) = NULL; \
CHECK_OBJ_NOTNULL((to), (type_magic)); \
} while (0)
#define REPLACE(ptr, val) \
do { \
if ((ptr) != NULL) \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment