More W32 resolver workarounds
[oweals/gnunet.git] / src / include / gnunet_common.h
index d599b87e945b9984634d4dd10f6373fa8610bd14..e4423f145729fbf50623801abffa8edf263b6207 100644 (file)
@@ -60,13 +60,13 @@ extern "C"
 /**
  * Version of the API (for entire gnunetutil.so library).
  */
-#define GNUNET_UTIL_VERSION 0x00090501
+#define GNUNET_UTIL_VERSION 0x000A0000
 
 /**
- * Named constants for return values.  The following
- * invariants hold: "GNUNET_NO == 0" (to allow "if (GNUNET_NO)")
- * "GNUNET_OK != GNUNET_SYSERR", "GNUNET_OK != GNUNET_NO", "GNUNET_NO != GNUNET_SYSERR"
- * and finally "GNUNET_YES != GNUNET_NO".
+ * Named constants for return values.  The following invariants hold:
+ * `GNUNET_NO == 0` (to allow `if (GNUNET_NO)`) `GNUNET_OK !=
+ * GNUNET_SYSERR`, `GNUNET_OK != GNUNET_NO`, `GNUNET_NO !=
+ * GNUNET_SYSERR` and finally `GNUNET_YES != GNUNET_NO`.
  */
 #define GNUNET_OK      1
 #define GNUNET_SYSERR -1
@@ -108,7 +108,7 @@ extern "C"
 
 /**
  * @ingroup logging
- * define GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source
+ * define #GNUNET_EXTRA_LOGGING if using this header outside the GNUnet source
  * tree where gnunet_config.h is unavailable
  */
 #ifndef GNUNET_EXTRA_LOGGING
@@ -217,7 +217,7 @@ extern "C"
 /**
  * Define as empty, GNUNET_PACKED should suffice, but this won't work on W32
  */
-#define GNUNET_NETWORK_STRUCT_BEGIN 
+#define GNUNET_NETWORK_STRUCT_BEGIN
 
 /**
  * Define as empty, GNUNET_PACKED should suffice, but this won't work on W32;
@@ -307,9 +307,9 @@ GNUNET_get_log_skip ();
 
 #if !defined(GNUNET_CULL_LOGGING)
 int
-GNUNET_get_log_call_status (int caller_level, 
+GNUNET_get_log_call_status (int caller_level,
                             const char *comp,
-                            const char *file, 
+                            const char *file,
                             const char *function, int line);
 #endif
 
@@ -403,7 +403,7 @@ GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
  * @param option name of missing option
  */
 void
-GNUNET_log_config_missing (enum GNUNET_ErrorType kind, 
+GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
                           const char *section,
                           const char *option);
 
@@ -418,7 +418,7 @@ GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
  * @param required what is required that is invalid about the option
  */
 void
-GNUNET_log_config_invalid (enum GNUNET_ErrorType kind, 
+GNUNET_log_config_invalid (enum GNUNET_ErrorType kind,
                           const char *section,
                           const char *option,
                           const char *required);
@@ -651,7 +651,7 @@ GNUNET_htonll (uint64_t n);
  * @param d the value in network byte order
  * @return the same value in host byte order
  */
-double 
+double
 GNUNET_hton_double (double d);
 
 /**
@@ -659,7 +659,7 @@ GNUNET_hton_double (double d);
  * @param d the value in network byte order
  * @return the same value in host byte order
  */
-double 
+double
 GNUNET_ntoh_double (double d);
 
 /* ************************* allocation functions ****************** */
@@ -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.
@@ -965,8 +976,6 @@ GNUNET_copy_message (const struct GNUNET_MessageHeader *msg);
 #endif
 
 
-
-
 #if 0                           /* keep Emacsens' auto-indent happy */
 {
 #endif