- use a memory-efficient, cleaner info API (limiting concurrent info requests to 1)
[oweals/gnunet.git] / src / include / gnunet_common.h
index e593826b78eff316a704cbc7ad649b28508c2e87..2a0ca33b210c5a00d142a89b10a03f950268b351 100644 (file)
@@ -376,7 +376,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
   }\
 } while (0)
 
-#define GNUNET_log(kind,...) do { int log_line = __LINE__;\
+ #define GNUNET_log(kind,...) do { int log_line = __LINE__;\
   static int log_call_enabled = GNUNET_LOG_CALL_STATUS;\
   if ((GNUNET_EXTRA_LOGGING > 0) || ((GNUNET_ERROR_TYPE_DEBUG & (kind)) == 0)) { \
     if (GN_UNLIKELY(log_call_enabled == -1))\
@@ -680,6 +680,17 @@ GNUNET_ntoh_double (double d);
  */
 #define GNUNET_new(type) (type *) GNUNET_malloc (sizeof (type))
 
+/**
+ * @ingroup memory
+ * Allocate a size @a n array with structs or unions of the given @a type.
+ * Wrapper around #GNUNET_malloc that returns a pointer
+ * to the newly created objects of the correct type.
+ *
+ * @param n number of elements in the array
+ * @param type name of the struct or union, i.e. pass 'struct Foo'.
+ */
+#define GNUNET_new_array(n, type) (type *) GNUNET_malloc ((n) * sizeof (type))
+
 /**
  * @ingroup memory
  * Wrapper around malloc. Allocates size bytes of memory.