diff options
Diffstat (limited to 'src/sanity.h')
-rw-r--r-- | src/sanity.h | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/src/sanity.h b/src/sanity.h index be77eef..cc8043f 100644 --- a/src/sanity.h +++ b/src/sanity.h @@ -8,16 +8,18 @@ #ifndef BFS_SANITY_H #define BFS_SANITY_H +#include "bfs.h" #include <stddef.h> -// Call macro(ptr, size) or macro(ptr, sizeof(*ptr)) -#define SANITIZE_CALL(...) \ - SANITIZE_CALL_(__VA_ARGS__, ) +/** Get the default size for a sanitize macro call. */ +#define SANITIZE_SIZE_(ptr, size) \ + BFS_VA_IF(size)(size)(sizeof(*ptr)) -#define SANITIZE_CALL_(macro, ptr, ...) \ - SANITIZE_CALL__(macro, ptr, __VA_ARGS__ sizeof(*(ptr)), ) +// Call macro(ptr, size) or macro(ptr, sizeof(*ptr)) +#define SANITIZE_CALL(macro, ptr, ...) \ + SANITIZE_CALL_(macro, ptr, SANITIZE_SIZE_(ptr, __VA_ARGS__)) -#define SANITIZE_CALL__(macro, ptr, size, ...) \ +#define SANITIZE_CALL_(macro, ptr, size) \ macro(ptr, size) #if __SANITIZE_ADDRESS__ |