GNUNET_NETWORK_STRUCT_BEGIN
+/**
+ * @brief A 512-bit hashcode. These are the default length for GNUnet, using SHA-512.
+ */
+struct GNUNET_HashCode
+{
+ uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
+};
+
+
+
+/**
+ * @brief A 256-bit hashcode. Used under special conditions, like when space
+ * is critical and security is not impacted by it.
+ */
+struct GNUNET_ShortHashCode
+{
+ uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */
+};
+
+
+
/**
* Header for all communications.
*/
*/
#define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type))
+
+/**
+ * Compare memory in @a a and @a b, where both must be of
+ * the same pointer type.
+ */
+#define GNUNET_memcmp(a,b) ({ \
+ const typeof(*b) * _a = (a); \
+ const typeof(*a) * _b = (b); \
+ memcmp(_a, \
+ _b, \
+ sizeof (*a)); })
+
+
+/**
+ * Check that memory in @a a is all zeros. @a a must be a pointer.
+ *
+ * @param a pointer to a struct which should be tested for the
+ * entire memory being zero'ed out.
+ */
+#define GNUNET_is_zero(a) ({ \
+ static const typeof(*a) _z; \
+ memcmp((a), \
+ &_z, \
+ sizeof (_z)); })
+
+
/**
* Call memcpy() but check for @a n being 0 first. In the latter
* case, it is now safe to pass NULL for @a src or @a dst.