32#if HAVE_MALLOC_MALLOC_H
33#include <malloc/malloc.h>
36#define LOG(kind, ...) \
37 GNUNET_log_from (kind, "util-common-allocation", __VA_ARGS__)
39#define LOG_STRERROR(kind, syscall) \
40 GNUNET_log_from_strerror (kind, "util-common-allocation", syscall)
43#define INT_MAX 0x7FFFFFFF
81 + n *
m * elementSize,
85 for (
size_t i = 0; i < n; i++)
88 + i *
m * elementSize;
103 + n *
m *
sizeof(
void *)
104 + n *
m * o * elementSize,
108 for (
size_t i = 0; i < n; i++)
111 ret[i] = (
char **) ((
char *)
ret
112 + n *
sizeof(
void **)
113 + i *
m *
sizeof(
void *));
114 for (
size_t j = 0; j <
m; j++)
116 + n *
sizeof(
void **)
117 + n *
m *
sizeof(
void *)
118 + i *
m * o * elementSize
119 + j * o * elementSize;
121 return (
void ***)
ret;
186 uint64_t *base = ptr;
187 size_t s = M_SIZE (ptr);
191 const uint64_t baadfood =
GNUNET_ntohll (0xBAADF00DBAADF00DLL);
198 for (
size_t i = 1 + (n + 7) / 8; i < s / 8; i++)
207 ptr = realloc (ptr, n);
208 if ((NULL == ptr) && (n > 0))
218#if __BYTE_ORDER == __LITTLE_ENDIAN
219#define BAADFOOD_STR "\x0D\xF0\xAD\xBA"
221#if __BYTE_ORDER == __BIG_ENDIAN
222#define BAADFOOD_STR "\xBA\xAD\xF0\x0D"
226#include <malloc_np.h>
228#if HAVE_MALLOC_USABLE_SIZE
229#define M_SIZE(p) malloc_usable_size (p)
230#elif HAVE_MALLOC_SIZE
231#define M_SIZE(p) malloc_size (p)
244 const uint64_t baadfood =
GNUNET_ntohll (0xBAADF00DBAADF00DLL);
245 uint64_t *base = ptr;
246 size_t s = M_SIZE (ptr);
248 for (
size_t i = 0; i < s / 8; i++)
263 size_t slen = strlen (str) + 1;
324 unsigned int *oldCount,
325 unsigned int newCount,
333 size = newCount * elementSize;
359 *oldCount = newCount;
373 ret = vsnprintf (NULL,
380 va_start (
args, format);
381 ret = vsprintf (*buf,
400 ret = vsnprintf (buf,
430 for (
size_t i = 0; i < n; i++)
struct GNUNET_MessageHeader * msg
static size_t strnlen(const char *s, size_t n)
int GNUNET_snprintf(char *buf, size_t size, const char *format,...)
int GNUNET_asprintf(char **buf, const char *format,...)
#define LOG_STRERROR(kind, syscall)
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static int ret
Final status code.
static char * res
Currently read line or NULL on EOF.
static int result
Global testing status.
char * GNUNET_xstrndup_(const char *str, size_t len, const char *filename, int linenumber)
Dup partially a string.
void GNUNET_xgrow_(void **old, size_t elementSize, unsigned int *oldCount, unsigned int newCount, const char *filename, int linenumber)
Grow an array, the new elements are zeroed out.
char * GNUNET_xstrdup_(const char *str, const char *filename, int linenumber)
Dup a string.
void ** GNUNET_xnew_array_2d_(size_t n, size_t m, size_t elementSize, const char *filename, int linenumber)
Allocate memory for a two dimensional array in one block and set up pointers.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
void * GNUNET_xmalloc_unchecked_(size_t size, const char *filename, int linenumber)
Allocate memory.
void GNUNET_xfree_(void *ptr, const char *filename, int linenumber)
Free memory.
void * GNUNET_xrealloc_(void *ptr, size_t n, const char *filename, int linenumber)
Reallocate memory.
void * GNUNET_xmalloc_(size_t size, const char *filename, int linenumber)
Allocate memory.
bool GNUNET_is_zero_(const void *a, size_t n)
Check that memory in a is all zeros.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
void *** GNUNET_xnew_array_3d_(size_t n, size_t m, size_t o, size_t elementSize, const char *filename, int linenumber)
Allocate memory for a three dimensional array in one block and set up pointers.
void * GNUNET_xmemdup_(const void *buf, size_t size, const char *filename, int linenumber)
Allocate and initialize memory.
uint16_t size
The length of the struct (in bytes, including the length field itself), in big-endian format.
#define GNUNET_assert(cond)
Use this for fatal errors that cannot be handled.
#define GNUNET_assert_at(cond, f, l)
Use this for fatal errors that cannot be handled.
@ GNUNET_ERROR_TYPE_ERROR
#define GNUNET_strdup(a)
Wrapper around GNUNET_xstrdup_.
#define GNUNET_MAX_MALLOC_CHECKED
Maximum allocation with GNUNET_malloc macro.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
#define GNUNET_malloc(size)
Wrapper around malloc.
static unsigned int size
Size of the "table".