[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[gnunet] branch master updated: fix #6153
From: |
gnunet |
Subject: |
[gnunet] branch master updated: fix #6153 |
Date: |
Fri, 03 Apr 2020 15:09:49 +0200 |
This is an automated email from the git hooks/post-receive script.
grothoff pushed a commit to branch master
in repository gnunet.
The following commit(s) were added to refs/heads/master by this push:
new 4e259dbbb fix #6153
4e259dbbb is described below
commit 4e259dbbba565c6f874ead9a8974175ffc6a2bb8
Author: Christian Grothoff <address@hidden>
AuthorDate: Fri Apr 3 15:05:14 2020 +0200
fix #6153
---
src/include/gnunet_common.h | 18 ++++++++++++++----
src/util/common_allocation.c | 20 ++++++++++++++++++++
2 files changed, 34 insertions(+), 4 deletions(-)
diff --git a/src/include/gnunet_common.h b/src/include/gnunet_common.h
index 6e185c314..6d9652a16 100644
--- a/src/include/gnunet_common.h
+++ b/src/include/gnunet_common.h
@@ -1098,6 +1098,19 @@ GNUNET_ntoh_double (double d);
})
+/**
+ * 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);
+
+
/**
* Check that memory in @a a is all zeros. @a a must be a pointer.
*
@@ -1106,10 +1119,7 @@ GNUNET_ntoh_double (double d);
* @return 0 if a is zero, non-zero otherwise
*/
#define GNUNET_is_zero(a) \
- ({ \
- static const typeof (*a) _z; \
- memcmp ((a), &_z, sizeof(_z)); \
- })
+ GNUNET_is_zero_ (a, sizeof (a))
/**
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 */
--
To stop receiving notification emails like this one, please contact
address@hidden.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [gnunet] branch master updated: fix #6153,
gnunet <=