diff options
author | Christian Grothoff <christian@grothoff.org> | 2020-04-03 15:05:14 +0200 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2020-04-03 15:05:14 +0200 |
commit | 4e259dbbba565c6f874ead9a8974175ffc6a2bb8 (patch) | |
tree | b167294e23ce87c3cf0405b7d7bcb7204bae081b /src/util | |
parent | 1b5dfc396ced80c42516ab134e3fe4b340f08e2f (diff) |
fix #6153
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/common_allocation.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/util/common_allocation.c b/src/util/common_allocation.c index 35c557000..5945fdcde 100644 --- a/src/util/common_allocation.c +++ b/src/util/common_allocation.c @@ -533,4 +533,24 @@ GNUNET_copy_message (const struct GNUNET_MessageHeader *msg) } +/** + * Check that memory in @a a is all zeros. @a a must be a pointer. + * + * @param a pointer to @a n bytes which should be tested for the + * entire memory being zero'ed out. + * @param n number of bytes in @a to be tested + * @return 0 if a is zero, non-zero otherwise + */ +int +GNUNET_is_zero_ (const void *a, + size_t n) +{ + const char *b = a; + for (size_t i = 0; i < n; i++) + if (b[i]) + return 0; + return 1; +} + + /* end of common_allocation.c */ |