Skip to content

Commit

Permalink
lib: i_zero*() - Give compiler error if it's wrongly used on an array
Browse files Browse the repository at this point in the history
  • Loading branch information
sirainen authored and cmouse committed Sep 14, 2018
1 parent 5c44ba8 commit 151ad1b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/lib/macros.h
Expand Up @@ -235,8 +235,10 @@
#endif

/* Convenience wrappers for initializing a struct */
#define i_zero(p) memset(p, 0, sizeof(*(p)))
#define i_zero_safe(p) safe_memset(p, 0, sizeof(*(p)))
#define i_zero(p) \
memset(p, 0 + + COMPILE_ERROR_IF_TRUE(sizeof(p) > sizeof(void *)), sizeof(*(p)))
#define i_zero_safe(p) \
safe_memset(p, 0 + + COMPILE_ERROR_IF_TRUE(sizeof(p) > sizeof(void *)), sizeof(*(p)))

#define ST_CHANGED(st_a, st_b) \
((st_a).st_mtime != (st_b).st_mtime || \
Expand Down

0 comments on commit 151ad1b

Please sign in to comment.