diff options
Diffstat (limited to 'src/util/common_allocation.c')
-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) | |||
533 | } | 533 | } |
534 | 534 | ||
535 | 535 | ||
536 | /** | ||
537 | * Check that memory in @a a is all zeros. @a a must be a pointer. | ||
538 | * | ||
539 | * @param a pointer to @a n bytes which should be tested for the | ||
540 | * entire memory being zero'ed out. | ||
541 | * @param n number of bytes in @a to be tested | ||
542 | * @return 0 if a is zero, non-zero otherwise | ||
543 | */ | ||
544 | int | ||
545 | GNUNET_is_zero_ (const void *a, | ||
546 | size_t n) | ||
547 | { | ||
548 | const char *b = a; | ||
549 | for (size_t i = 0; i < n; i++) | ||
550 | if (b[i]) | ||
551 | return 0; | ||
552 | return 1; | ||
553 | } | ||
554 | |||
555 | |||
536 | /* end of common_allocation.c */ | 556 | /* end of common_allocation.c */ |