#endif
#ifdef __cplusplus
-extern "C"
-{
-#if 0 /* keep Emacsens' auto-indent happy */
+extern "C" {
+#if 0 /* keep Emacsens' auto-indent happy */
}
#endif
#endif
* GNUNET_SYSERR`, `GNUNET_OK != GNUNET_NO`, `GNUNET_NO !=
* GNUNET_SYSERR` and finally `GNUNET_YES != GNUNET_NO`.
*/
-#define GNUNET_OK 1
+#define GNUNET_OK 1
#define GNUNET_SYSERR -1
-#define GNUNET_YES 1
-#define GNUNET_NO 0
+#define GNUNET_YES 1
+#define GNUNET_NO 0
-#define GNUNET_MIN(a,b) (((a) < (b)) ? (a) : (b))
+#define GNUNET_MIN(a, b) (((a) < (b)) ? (a) : (b))
-#define GNUNET_MAX(a,b) (((a) > (b)) ? (a) : (b))
+#define GNUNET_MAX(a, b) (((a) > (b)) ? (a) : (b))
/* some systems use one underscore only, and mingw uses no underscore... */
#ifndef __BYTE_ORDER
/**
* wrap va_arg for enums
*/
-#define GNUNET_VA_ARG_ENUM(va,X) ((enum X) va_arg (va, int))
+#define GNUNET_VA_ARG_ENUM(va, X) ((enum X) va_arg (va, int))
/**
* Endian operations
*/
-# if __BYTE_ORDER == __LITTLE_ENDIAN
-# define GNUNET_htobe16(x) __bswap_16 (x)
-# define GNUNET_htole16(x) (x)
-# define GNUNET_be16toh(x) __bswap_16 (x)
-# define GNUNET_le16toh(x) (x)
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define GNUNET_htobe16(x) __bswap_16 (x)
+#define GNUNET_htole16(x) (x)
+#define GNUNET_be16toh(x) __bswap_16 (x)
+#define GNUNET_le16toh(x) (x)
-# define GNUNET_htobe32(x) __bswap_32 (x)
-# define GNUNET_htole32(x) (x)
-# define GNUNET_be32toh(x) __bswap_32 (x)
-# define GNUNET_le32toh(x) (x)
+#define GNUNET_htobe32(x) __bswap_32 (x)
+#define GNUNET_htole32(x) (x)
+#define GNUNET_be32toh(x) __bswap_32 (x)
+#define GNUNET_le32toh(x) (x)
-# define GNUNET_htobe64(x) __bswap_64 (x)
-# define GNUNET_htole64(x) (x)
-# define GNUNET_be64toh(x) __bswap_64 (x)
-# define GNUNET_le64toh(x) (x)
+#define GNUNET_htobe64(x) __bswap_64 (x)
+#define GNUNET_htole64(x) (x)
+#define GNUNET_be64toh(x) __bswap_64 (x)
+#define GNUNET_le64toh(x) (x)
#endif
-# if __BYTE_ORDER == __BIG_ENDIAN
-# define GNUNET_htobe16(x) (x)
-# define GNUNET_htole16(x) __bswap_16 (x)
-# define GNUNET_be16toh(x) (x)
-# define GNUNET_le16toh(x) __bswap_16 (x)
-
-# define GNUNET_htobe32(x) (x)
-# define GNUNET_htole32(x) __bswap_32 (x)
-# define GNUNET_be32toh(x) (x)
-# define GNUNET_le32toh(x) __bswap_32 (x)
-
-# define GNUNET_htobe64(x) (x)
-# define GNUNET_htole64(x) __bswap_64 (x)
-# define GNUNET_be64toh(x) (x)
-# define GNUNET_le64toh(x) __bswap_64 (x)
+#if __BYTE_ORDER == __BIG_ENDIAN
+#define GNUNET_htobe16(x) (x)
+#define GNUNET_htole16(x) __bswap_16 (x)
+#define GNUNET_be16toh(x) (x)
+#define GNUNET_le16toh(x) __bswap_16 (x)
+
+#define GNUNET_htobe32(x) (x)
+#define GNUNET_htole32(x) __bswap_32 (x)
+#define GNUNET_be32toh(x) (x)
+#define GNUNET_le32toh(x) __bswap_32 (x)
+
+#define GNUNET_htobe64(x) (x)
+#define GNUNET_htole64(x) __bswap_64 (x)
+#define GNUNET_be64toh(x) (x)
+#define GNUNET_le64toh(x) __bswap_64 (x)
#endif
* on the stack with a variable-length that might be zero, write
* "int[GNUNET_NZL(n)] x;" instead of "int[n] x".
*/
-#define GNUNET_NZL(l) GNUNET_MAX(1,l)
+#define GNUNET_NZL(l) GNUNET_MAX (1, l)
/**
* gcc-ism to get packed structs.
*/
-#define GNUNET_PACKED __attribute__((packed))
+#define GNUNET_PACKED __attribute__ ((packed))
/**
* gcc-ism to get gcc bitfield layout when compiling with -mms-bitfields
*/
#if MINGW
-#define GNUNET_GCC_STRUCT_LAYOUT __attribute__((gcc_struct))
+#define GNUNET_GCC_STRUCT_LAYOUT __attribute__ ((gcc_struct))
#else
#define GNUNET_GCC_STRUCT_LAYOUT
#endif
* bug #33594.
*/
#ifdef __BIGGEST_ALIGNMENT__
-#define GNUNET_ALIGN __attribute__((aligned (__BIGGEST_ALIGNMENT__)))
+#define GNUNET_ALIGN __attribute__ ((aligned (__BIGGEST_ALIGNMENT__)))
#else
-#define GNUNET_ALIGN __attribute__((aligned (8)))
+#define GNUNET_ALIGN __attribute__ ((aligned (8)))
#endif
/**
* gcc-ism to document unused arguments
*/
-#define GNUNET_UNUSED __attribute__((unused))
+#define GNUNET_UNUSED __attribute__ ((unused))
/**
* gcc-ism to document functions that don't return
*/
-#define GNUNET_NORETURN __attribute__((noreturn))
+#define GNUNET_NORETURN __attribute__ ((noreturn))
#if MINGW
#if __GNUC__ > 3
* so we *only* use this on W32 (see #670578 from Debian); fortunately,
* W32 doesn't run on sparc anyway.
*/
-#define GNUNET_NETWORK_STRUCT_BEGIN \
- _Pragma("pack(push)") \
- _Pragma("pack(1)")
+#define GNUNET_NETWORK_STRUCT_BEGIN _Pragma ("pack(push)") _Pragma ("pack(1)")
/**
* gcc 4.x-ism to pack structures even on W32 (to be used after structs)
* so we *only* use this on W32 (see #670578 from Debian); fortunately,
* W32 doesn't run on sparc anyway.
*/
-#define GNUNET_NETWORK_STRUCT_END _Pragma("pack(pop)")
+#define GNUNET_NETWORK_STRUCT_END _Pragma ("pack(pop)")
#else
#error gcc 4.x or higher required on W32 systems
*/
struct GNUNET_HashCode
{
- uint32_t bits[512 / 8 / sizeof (uint32_t)]; /* = 16 */
+ 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 */
+ uint32_t bits[256 / 8 / sizeof (uint32_t)]; /* = 8 */
};
-
/**
* Header for all communications.
*/
* The type of the message (GNUNET_MESSAGE_TYPE_XXXX), in big-endian format.
*/
uint16_t type GNUNET_PACKED;
-
};
*/
struct GNUNET_AsyncScopeId
{
- uint32_t bits[16 / sizeof (uint32_t)]; /* = 16 bytes */
+ uint32_t bits[16 / sizeof (uint32_t)]; /* = 16 bytes */
};
GNUNET_NETWORK_STRUCT_END
/**
* Saved async scope identifier or root scope.
*/
-struct GNUNET_AsyncScopeSave {
+struct GNUNET_AsyncScopeSave
+{
/**
* Saved scope. Unused if 'have_scope==GNUNET_NO'.
*/
* #GNUNET_NO to stop iteration with no error,
* #GNUNET_SYSERR to abort iteration with error!
*/
-typedef int
-(*GNUNET_FileNameCallback) (void *cls,
- const char *filename);
+typedef int (*GNUNET_FileNameCallback) (void *cls, const char *filename);
/**
*
* @param cls Closure.
*/
-typedef void
-(*GNUNET_ContinuationCallback) (void *cls);
+typedef void (*GNUNET_ContinuationCallback) (void *cls);
/**
* @param data_size
* Size of @a data.
*/
-typedef void
-(*GNUNET_ResultCallback) (void *cls, int64_t result_code,
- const void *data, uint16_t data_size);
+typedef void (*GNUNET_ResultCallback) (void *cls,
+ int64_t result_code,
+ const void *data,
+ uint16_t data_size);
/* ****************************** logging ***************************** */
* @param date when was the message logged?
* @param message what is the message
*/
-typedef void
-(*GNUNET_Logger) (void *cls,
- enum GNUNET_ErrorType kind,
- const char *component,
- const char *date,
- const char *message);
+typedef void (*GNUNET_Logger) (void *cls,
+ enum GNUNET_ErrorType kind,
+ const char *component,
+ const char *date,
+ const char *message);
/**
GNUNET_get_log_skip (void);
-#if !defined(GNUNET_CULL_LOGGING)
+#if ! defined(GNUNET_CULL_LOGGING)
int
GNUNET_get_log_call_status (int caller_level,
const char *comp,
/* from glib */
#if defined(__GNUC__) && (__GNUC__ > 2) && defined(__OPTIMIZE__)
-#define _GNUNET_BOOLEAN_EXPR(expr) \
- __extension__ ({ \
- int _gnunet_boolean_var_; \
- if (expr) \
- _gnunet_boolean_var_ = 1; \
- else \
- _gnunet_boolean_var_ = 0; \
- _gnunet_boolean_var_; \
-})
-#define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR(expr), 1))
-#define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR(expr), 0))
+#define _GNUNET_BOOLEAN_EXPR(expr) \
+ __extension__({ \
+ int _gnunet_boolean_var_; \
+ if (expr) \
+ _gnunet_boolean_var_ = 1; \
+ else \
+ _gnunet_boolean_var_ = 0; \
+ _gnunet_boolean_var_; \
+ })
+#define GN_LIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 1))
+#define GN_UNLIKELY(expr) (__builtin_expect (_GNUNET_BOOLEAN_EXPR (expr), 0))
#else
#define GN_LIKELY(expr) (expr)
#define GN_UNLIKELY(expr) (expr)
#endif
-#if !defined(GNUNET_LOG_CALL_STATUS)
+#if ! defined(GNUNET_LOG_CALL_STATUS)
#define GNUNET_LOG_CALL_STATUS -1
#endif
* @param ... arguments for format string
*/
void
-GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind, const char *comp,
- const char *message, ...);
-
-#if !defined(GNUNET_CULL_LOGGING)
-#define GNUNET_log_from(kind,comp,...) 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))\
- log_call_enabled = GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), (comp), __FILE__, __FUNCTION__, log_line); \
- if (GN_UNLIKELY(GNUNET_get_log_skip () > 0)) { GNUNET_log_skip (-1, GNUNET_NO); }\
- else {\
- if (GN_UNLIKELY(log_call_enabled))\
- GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
- }\
- }\
-} while (0)
-
- #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))\
- log_call_enabled = GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), NULL, __FILE__, __FUNCTION__, log_line);\
- if (GN_UNLIKELY(GNUNET_get_log_skip () > 0)) { GNUNET_log_skip (-1, GNUNET_NO); }\
- else {\
- if (GN_UNLIKELY(log_call_enabled))\
- GNUNET_log_nocheck ((kind), __VA_ARGS__); \
- }\
- }\
-} while (0)
+GNUNET_log_from_nocheck (enum GNUNET_ErrorType kind,
+ const char *comp,
+ const char *message,
+ ...);
+
+#if ! defined(GNUNET_CULL_LOGGING)
+#define GNUNET_log_from(kind, comp, ...) \
+ 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)) \
+ log_call_enabled = \
+ GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
+ (comp), \
+ __FILE__, \
+ __FUNCTION__, \
+ log_line); \
+ if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
+ { \
+ GNUNET_log_skip (-1, GNUNET_NO); \
+ } \
+ else \
+ { \
+ if (GN_UNLIKELY (log_call_enabled)) \
+ GNUNET_log_from_nocheck ((kind), comp, __VA_ARGS__); \
+ } \
+ } \
+ } while (0)
+
+#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)) \
+ log_call_enabled = \
+ GNUNET_get_log_call_status ((kind) & (~GNUNET_ERROR_TYPE_BULK), \
+ NULL, \
+ __FILE__, \
+ __FUNCTION__, \
+ log_line); \
+ if (GN_UNLIKELY (GNUNET_get_log_skip () > 0)) \
+ { \
+ GNUNET_log_skip (-1, GNUNET_NO); \
+ } \
+ else \
+ { \
+ if (GN_UNLIKELY (log_call_enabled)) \
+ GNUNET_log_nocheck ((kind), __VA_ARGS__); \
+ } \
+ } \
+ } while (0)
#else
#define GNUNET_log(...)
#define GNUNET_log_from(...)
*/
void
GNUNET_log_config_missing (enum GNUNET_ErrorType kind,
- const char *section,
- const char *option);
+ const char *section,
+ const char *option);
/**
*/
void
GNUNET_log_config_invalid (enum GNUNET_ErrorType kind,
- const char *section,
- const char *option,
- const char *required);
+ const char *section,
+ const char *option,
+ const char *required);
/**
* @param check_reset #GNUNET_YES to assert that the log skip counter is currently zero
*/
void
-GNUNET_log_skip (int n,
- int check_reset);
+GNUNET_log_skip (int n, int check_reset);
/**
* @return #GNUNET_OK on success, #GNUNET_SYSERR if logfile could not be opened
*/
int
-GNUNET_log_setup (const char *comp,
- const char *loglevel,
- const char *logfile);
+GNUNET_log_setup (const char *comp, const char *loglevel, const char *logfile);
/**
* @param logger_cls closure for @a logger
*/
void
-GNUNET_logger_add (GNUNET_Logger logger,
- void *logger_cls);
+GNUNET_logger_add (GNUNET_Logger logger, void *logger_cls);
/**
* @param logger_cls closure for @a logger
*/
void
-GNUNET_logger_remove (GNUNET_Logger logger,
- void *logger_cls);
+GNUNET_logger_remove (GNUNET_Logger logger, void *logger_cls);
/**
* will be overwritten by next call to #GNUNET_a2s().
*/
const char *
-GNUNET_a2s (const struct sockaddr *addr,
- socklen_t addrlen);
+GNUNET_a2s (const struct sockaddr *addr, socklen_t addrlen);
/**
* @ingroup logging
* Use this for fatal errors that cannot be handled
*/
-#define GNUNET_assert(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d. Aborting.\n"), __FILE__, __LINE__); GNUNET_abort_(); } } while(0)
+#define GNUNET_assert(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
+ _ ("Assertion failed at %s:%d. Aborting.\n"), \
+ __FILE__, \
+ __LINE__); \
+ GNUNET_abort_ (); \
+ } \
+ } while (0)
/**
* @ingroup logging
* Use this for fatal errors that cannot be handled
*/
-#define GNUNET_assert_at(cond, f, l) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d. Aborting.\n"), f, l); GNUNET_abort_(); } } while(0)
+#define GNUNET_assert_at(cond, f, l) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
+ _ ("Assertion failed at %s:%d. Aborting.\n"), \
+ f, \
+ l); \
+ GNUNET_abort_ (); \
+ } \
+ } while (0)
/**
* @param cond Condition to evaluate
* @param comp Component string to use for logging
*/
-#define GNUNET_assert_from(cond, comp) do { if (! (cond)) { GNUNET_log_from(GNUNET_ERROR_TYPE_ERROR, comp, _("Assertion failed at %s:%d. Aborting.\n"), __FILE__, __LINE__); GNUNET_abort_(); } } while(0)
+#define GNUNET_assert_from(cond, comp) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log_from (GNUNET_ERROR_TYPE_ERROR, \
+ comp, \
+ _ ("Assertion failed at %s:%d. Aborting.\n"), \
+ __FILE__, \
+ __LINE__); \
+ GNUNET_abort_ (); \
+ } \
+ } while (0)
/**
* Use this for internal assertion violations that are
* not fatal (can be handled) but should not occur.
*/
-#define GNUNET_break(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_ERROR, _("Assertion failed at %s:%d.\n"), __FILE__, __LINE__); } } while(0)
+#define GNUNET_break(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR, \
+ _ ("Assertion failed at %s:%d.\n"), \
+ __FILE__, \
+ __LINE__); \
+ } \
+ } while (0)
/**
* we still want to see these problems during
* development and testing. "OP == other peer".
*/
-#define GNUNET_break_op(cond) do { if (! (cond)) { GNUNET_log(GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, _("External protocol violation detected at %s:%d.\n"), __FILE__, __LINE__); } } while(0)
+#define GNUNET_break_op(cond) \
+ do \
+ { \
+ if (! (cond)) \
+ { \
+ GNUNET_log (GNUNET_ERROR_TYPE_WARNING | GNUNET_ERROR_TYPE_BULK, \
+ _ ("External protocol violation detected at %s:%d.\n"), \
+ __FILE__, \
+ __LINE__); \
+ } \
+ } while (0)
/**
* a failure of the command 'cmd' with the message given
* by strerror(errno).
*/
-#define GNUNET_log_strerror(level, cmd) do { GNUNET_log(level, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0)
+#define GNUNET_log_strerror(level, cmd) \
+ do \
+ { \
+ GNUNET_log (level, \
+ _ ("`%s' failed at %s:%d with error: %s\n"), \
+ cmd, \
+ __FILE__, \
+ __LINE__, \
+ STRERROR (errno)); \
+ } while (0)
/**
* a failure of the command 'cmd' with the message given
* by strerror(errno).
*/
-#define GNUNET_log_from_strerror(level, component, cmd) do { GNUNET_log_from (level, component, _("`%s' failed at %s:%d with error: %s\n"), cmd, __FILE__, __LINE__, STRERROR(errno)); } while(0)
+#define GNUNET_log_from_strerror(level, component, cmd) \
+ do \
+ { \
+ GNUNET_log_from (level, \
+ component, \
+ _ ("`%s' failed at %s:%d with error: %s\n"), \
+ cmd, \
+ __FILE__, \
+ __LINE__, \
+ STRERROR (errno)); \
+ } while (0)
/**
* a failure of the command 'cmd' with the message given
* by strerror(errno).
*/
-#define GNUNET_log_strerror_file(level, cmd, filename) do { GNUNET_log(level, _("`%s' failed on file `%s' at %s:%d with error: %s\n"), cmd, filename, __FILE__, __LINE__, STRERROR(errno)); } while(0)
+#define GNUNET_log_strerror_file(level, cmd, filename) \
+ do \
+ { \
+ GNUNET_log (level, \
+ _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
+ cmd, \
+ filename, \
+ __FILE__, \
+ __LINE__, \
+ STRERROR (errno)); \
+ } while (0)
/**
* a failure of the command 'cmd' with the message given
* by strerror(errno).
*/
-#define GNUNET_log_from_strerror_file(level, component, cmd, filename) do { GNUNET_log_from (level, component, _("`%s' failed on file `%s' at %s:%d with error: %s\n"), cmd, filename,__FILE__, __LINE__, STRERROR(errno)); } while(0)
+#define GNUNET_log_from_strerror_file(level, component, cmd, filename) \
+ do \
+ { \
+ GNUNET_log_from (level, \
+ component, \
+ _ ("`%s' failed on file `%s' at %s:%d with error: %s\n"), \
+ cmd, \
+ filename, \
+ __FILE__, \
+ __LINE__, \
+ STRERROR (errno)); \
+ } while (0)
/* ************************* endianess conversion ****************** */
* 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)); })
+#define GNUNET_memcmp(a, b) \
+ ({ \
+ const typeof (*b) *_a = (a); \
+ const typeof (*a) *_b = (b); \
+ memcmp (_a, _b, sizeof (*a)); \
+ })
/**
* @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)); })
+#define GNUNET_is_zero(a) \
+ ({ \
+ static const typeof (*a) _z; \
+ memcmp ((a), &_z, sizeof (_z)); \
+ })
/**
* @param src source of the copy, may be NULL if @a n is zero
* @param n number of bytes to copy
*/
-#define GNUNET_memcpy(dst,src,n) do { if (0 != n) { (void) memcpy (dst,src,n); } } while (0)
+#define GNUNET_memcpy(dst, src, n) \
+ do \
+ { \
+ if (0 != n) \
+ { \
+ (void) memcpy (dst, src, n); \
+ } \
+ } while (0)
/**
* @param m size of the second dimension
* @param type name of the struct or union, i.e. pass 'struct Foo'.
*/
-#define GNUNET_new_array_2d(n, m, type) (type **) GNUNET_xnew_array_2d_ (n, m, sizeof (type), __FILE__, __LINE__)
+#define GNUNET_new_array_2d(n, m, type) \
+ (type **) GNUNET_xnew_array_2d_ (n, m, sizeof (type), __FILE__, __LINE__)
/**
* @ingroup memory
* @param o size of the third dimension
* @param type name of the struct or union, i.e. pass 'struct Foo'.
*/
-#define GNUNET_new_array_3d(n, m, o, type) (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof (type), __FILE__, __LINE__)
+#define GNUNET_new_array_3d(n, m, o, type) \
+ (type ***) GNUNET_xnew_array_3d_ (n, m, o, sizeof (type), __FILE__, __LINE__)
/**
* @ingroup memory
* smaller than 40 MB.
* @return pointer to size bytes of memory, never NULL (!)
*/
-#define GNUNET_malloc(size) GNUNET_xmalloc_(size, __FILE__, __LINE__)
+#define GNUNET_malloc(size) GNUNET_xmalloc_ (size, __FILE__, __LINE__)
/**
* @ingroup memory
* @param size the number of bytes in buf (and size of the allocation)
* @return pointer to size bytes of memory, never NULL (!)
*/
-#define GNUNET_memdup(buf,size) GNUNET_xmemdup_(buf, size, __FILE__, __LINE__)
+#define GNUNET_memdup(buf, size) GNUNET_xmemdup_ (buf, size, __FILE__, __LINE__)
/**
* @ingroup memory
* @param size the number of bytes to allocate
* @return pointer to size bytes of memory, NULL if we do not have enough memory
*/
-#define GNUNET_malloc_large(size) GNUNET_xmalloc_unchecked_(size, __FILE__, __LINE__)
+#define GNUNET_malloc_large(size) \
+ GNUNET_xmalloc_unchecked_ (size, __FILE__, __LINE__)
/**
* @ingroup memory
* @param size the number of bytes to reallocate
* @return pointer to size bytes of memory
*/
-#define GNUNET_realloc(ptr, size) GNUNET_xrealloc_(ptr, size, __FILE__, __LINE__)
+#define GNUNET_realloc(ptr, size) \
+ GNUNET_xrealloc_ (ptr, size, __FILE__, __LINE__)
/**
* @ingroup memory
* @param ptr location where to free the memory. ptr must have
* been returned by #GNUNET_strdup, #GNUNET_strndup, #GNUNET_malloc or #GNUNET_array_grow earlier.
*/
-#define GNUNET_free(ptr) GNUNET_xfree_(ptr, __FILE__, __LINE__)
+#define GNUNET_free(ptr) GNUNET_xfree_ (ptr, __FILE__, __LINE__)
/**
* @ingroup memory
*
* @param ptr the location in memory to free
*/
-#define GNUNET_free_non_null(ptr) do { void * __x__ = ptr; if (__x__ != NULL) { GNUNET_free(__x__); } } while(0)
+#define GNUNET_free_non_null(ptr) \
+ do \
+ { \
+ void *__x__ = ptr; \
+ if (__x__ != NULL) \
+ { \
+ GNUNET_free (__x__); \
+ } \
+ } while (0)
/**
* @ingroup memory
* @param a pointer to a zero-terminated string
* @return a copy of the string including zero-termination
*/
-#define GNUNET_strdup(a) GNUNET_xstrdup_(a,__FILE__,__LINE__)
+#define GNUNET_strdup(a) GNUNET_xstrdup_ (a, __FILE__, __LINE__)
/**
* @ingroup memory
* @param length of the string to duplicate
* @return a partial copy of the string including zero-termination
*/
-#define GNUNET_strndup(a,length) GNUNET_xstrndup_(a,length,__FILE__,__LINE__)
+#define GNUNET_strndup(a, length) \
+ GNUNET_xstrndup_ (a, length, __FILE__, __LINE__)
/**
* @ingroup memory
* @param tsize the target size for the resulting vector, use 0 to
* free the vector (then, arr will be NULL afterwards).
*/
-#define GNUNET_array_grow(arr,size,tsize) GNUNET_xgrow_((void**)&(arr), sizeof((arr)[0]), &size, tsize, __FILE__, __LINE__)
+#define GNUNET_array_grow(arr, size, tsize) \
+ GNUNET_xgrow_ ((void **) &(arr), \
+ sizeof ((arr)[0]), \
+ &size, \
+ tsize, \
+ __FILE__, \
+ __LINE__)
/**
* @ingroup memory
* array size
* @param element the element that will be appended to the array
*/
-#define GNUNET_array_append(arr,size,element) do { GNUNET_array_grow(arr,size,size+1); (arr)[size-1] = element; } while(0)
+#define GNUNET_array_append(arr, size, element) \
+ do \
+ { \
+ GNUNET_array_grow (arr, size, size + 1); \
+ (arr)[size - 1] = element; \
+ } while (0)
/**
* @ingroup memory
* @return allocated memory, never NULL
*/
void **
-GNUNET_xnew_array_2d_ (size_t n, size_t m, size_t elementSize,
- const char *filename, int linenumber);
+GNUNET_xnew_array_2d_ (size_t n,
+ size_t m,
+ size_t elementSize,
+ const char *filename,
+ int linenumber);
/**
* @return allocated memory, never NULL
*/
void ***
-GNUNET_xnew_array_3d_ (size_t n, size_t m, size_t o, size_t elementSize,
- const char *filename, int linenumber);
+GNUNET_xnew_array_3d_ (size_t n,
+ size_t m,
+ size_t o,
+ size_t elementSize,
+ const char *filename,
+ int linenumber);
/**
* @return allocated memory, never NULL
*/
void *
-GNUNET_xmemdup_ (const void *buf, size_t size, const char *filename,
+GNUNET_xmemdup_ (const void *buf,
+ size_t size,
+ const char *filename,
int linenumber);
* @return the duplicated string
*/
char *
-GNUNET_xstrndup_ (const char *str, size_t len, const char *filename,
+GNUNET_xstrndup_ (const char *str,
+ size_t len,
+ const char *filename,
int linenumber);
/**
* @param linenumber line where this call is being made (for debugging)
*/
void
-GNUNET_xgrow_ (void **old, size_t elementSize, unsigned int *oldCount,
- unsigned int newCount, const char *filename, int linenumber);
+GNUNET_xgrow_ (void **old,
+ size_t elementSize,
+ unsigned int *oldCount,
+ unsigned int newCount,
+ const char *filename,
+ int linenumber);
/**
};
-#if 0 /* keep Emacsens' auto-indent happy */
+#if 0 /* keep Emacsens' auto-indent happy */
{
#endif
#ifdef __cplusplus