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
100 + n *
m * elementSize,
104 for (
size_t i = 0; i < n; i++)
107 + i *
m * elementSize;
108 return (
void **)
ret;
137 + n *
m *
sizeof(
void *)
138 + n *
m * o * elementSize,
142 for (
size_t i = 0; i < n; i++)
145 ret[i] = (
char **) ((
char *)
ret
146 + n *
sizeof(
void **)
147 + i *
m *
sizeof(
void *));
148 for (
size_t j = 0; j <
m; j++)
150 + n *
sizeof(
void **)
151 + n *
m *
sizeof(
void *)
152 + i *
m * o * elementSize
153 + j * o * elementSize;
155 return (
void ***)
ret;
228 uint64_t *base = ptr;
229 size_t s = M_SIZE (ptr);
233 const uint64_t baadfood =
GNUNET_ntohll (0xBAADF00DBAADF00DLL);
240 for (
size_t i = 1 + (n + 7) / 8; i < s / 8; i++)
249 ptr = realloc (ptr, n);
250 if ((NULL == ptr) && (n > 0))
259 #if __BYTE_ORDER == __LITTLE_ENDIAN
260 #define BAADFOOD_STR "\x0D\xF0\xAD\xBA"
262 #if __BYTE_ORDER == __BIG_ENDIAN
263 #define BAADFOOD_STR "\xBA\xAD\xF0\x0D"
267 #include <malloc_np.h>
269 #if HAVE_MALLOC_USABLE_SIZE
270 #define M_SIZE(p) malloc_usable_size (p)
271 #elif HAVE_MALLOC_SIZE
272 #define M_SIZE(p) malloc_size (p)
293 const uint64_t baadfood =
GNUNET_ntohll (0xBAADF00DBAADF00DLL);
294 uint64_t *base = ptr;
295 size_t s = M_SIZE (ptr);
297 for (
size_t i = 0; i < s / 8; i++)
322 slen = strlen (str) + 1;
335 e = memchr (s,
'\0', n);
388 unsigned int *oldCount,
389 unsigned int newCount,
397 size = newCount * elementSize;
416 *oldCount = newCount;
434 va_start (
args, format);
435 ret = vsnprintf (NULL, 0, format,
args);
439 va_start (
args, format);
461 va_start (
args, format);
497 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,...)
Like snprintf(), just aborts if the buffer is of insufficient size.
int GNUNET_asprintf(char **buf, const char *format,...)
Like asprintf(), just portable.
#define LOG_STRERROR(kind, syscall)
static int ret
Return value of the commandline.
static struct GNUNET_ARM_MonitorHandle * m
Monitor connection with ARM.
static struct Experiment * e
uint16_t len
length of data (which is always a uint32_t, but presumably this can be used to specify that fewer byt...
static int result
Global testing status.
enum GNUNET_GenericReturnValue GNUNET_is_zero_(const void *a, size_t n)
Check that memory in a is all zeros.
char * GNUNET_xstrdup_(const char *str, const char *filename, int linenumber)
Dup a string (same semantics as strdup).
void * GNUNET_xrealloc_(void *ptr, size_t n, const char *filename, int linenumber)
Reallocate memory.
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.
void GNUNET_xgrow_(void **old, size_t elementSize, unsigned int *oldCount, unsigned int newCount, const char *filename, int linenumber)
Grow an array.
void * GNUNET_xmalloc_(size_t size, const char *filename, int linenumber)
Allocate memory.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
void GNUNET_xfree_(void *ptr, const char *filename, int linenumber)
Free memory.
void * GNUNET_xmemdup_(const void *buf, size_t size, const char *filename, int linenumber)
Allocate and initialize memory.
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.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
char * GNUNET_xstrndup_(const char *str, size_t len, const char *filename, int linenumber)
Dup partially a string (same semantics as strndup).
GNUNET_GenericReturnValue
Named constants for return values.
void * GNUNET_xmalloc_unchecked_(size_t size, const char *filename, int linenumber)
Wrapper around malloc().
#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.
#define GNUNET_malloc(size)
Wrapper around malloc.
struct GNUNET_MessageHeader * GNUNET_copy_message(const struct GNUNET_MessageHeader *msg)
Create a copy of the given message.
static unsigned int size
Size of the "table".