31 #if HAVE_MALLOC_MALLOC_H
32 #include <malloc/malloc.h>
35 #define LOG(kind, ...) \
36 GNUNET_log_from (kind, "util-common-allocation", __VA_ARGS__)
38 #define LOG_STRERROR(kind, syscall) \
39 GNUNET_log_from_strerror (kind, "util-common-allocation", syscall)
42 #define INT_MAX 0x7FFFFFFF
99 + n *
m * elementSize,
103 for (
size_t i = 0; i < n; i++)
106 + i *
m * elementSize;
107 return (
void **)
ret;
136 + n *
m *
sizeof(
void *)
137 + n *
m * o * elementSize,
141 for (
size_t i = 0; i < n; i++)
144 ret[i] = (
char **) ((
char *)
ret
145 + n *
sizeof(
void **)
146 + i *
m *
sizeof(
void *));
147 for (
size_t j = 0; j <
m; j++)
149 + n *
sizeof(
void **)
150 + n *
m *
sizeof(
void *)
151 + i *
m * o * elementSize
152 + j * o * elementSize;
154 return (
void ***)
ret;
238 uint64_t *base = ptr;
239 size_t s = M_SIZE (ptr);
243 const uint64_t baadfood =
GNUNET_ntohll (0xBAADF00DBAADF00DLL);
250 for (
size_t i = 1 + (n + 7) / 8; i < s / 8; i++)
259 ptr = realloc (ptr, n);
260 if ((NULL == ptr) && (n > 0))
269 #if __BYTE_ORDER == __LITTLE_ENDIAN
270 #define BAADFOOD_STR "\x0D\xF0\xAD\xBA"
272 #if __BYTE_ORDER == __BIG_ENDIAN
273 #define BAADFOOD_STR "\xBA\xAD\xF0\x0D"
277 #include <malloc_np.h>
279 #if HAVE_MALLOC_USABLE_SIZE
280 #define M_SIZE(p) malloc_usable_size (p)
281 #elif HAVE_MALLOC_SIZE
282 #define M_SIZE(p) malloc_size (p)
303 const uint64_t baadfood =
GNUNET_ntohll (0xBAADF00DBAADF00DLL);
304 uint64_t *base = ptr;
305 size_t s = M_SIZE (ptr);
307 for (
size_t i = 0; i < s / 8; i++)
332 slen = strlen (str) + 1;
345 e = memchr (s,
'\0', n);
398 unsigned int *oldCount,
399 unsigned int newCount,
407 size = newCount * elementSize;
426 *oldCount = newCount;
444 va_start (
args, format);
445 ret = vsnprintf (NULL, 0, format,
args);
449 va_start (
args, format);
471 va_start (
args, format);
513 for (
size_t i = 0; i < n; i++)
struct GNUNET_MessageHeader * msg
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.
static size_t strnlen(const char *s, size_t n)
void GNUNET_xfree_(void *ptr, const char *filename, int linenumber)
Free memory.
void * GNUNET_xmalloc_(size_t size, const char *filename, int linenumber)
Allocate memory.
void * GNUNET_xmemdup_(const void *buf, size_t size, const char *filename, int linenumber)
Allocate and initialize memory.
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.
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.
char * GNUNET_xstrndup_(const char *str, size_t len, const char *filename, int linenumber)
Dup partially a string (same semantics as strndup).
#define LOG_STRERROR(kind, syscall)
void * GNUNET_xmalloc_unchecked_(size_t size, const char *filename, int linenumber)
Wrapper around malloc().
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.
uint64_t GNUNET_ntohll(uint64_t n)
Convert unsigned 64-bit integer to host byte order.
#define GNUNET_memcpy(dst, src, n)
Call memcpy() but check for n being 0 first.
GNUNET_GenericReturnValue
Named constants for return values.
cryptographic primitives for GNUnet
#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".