diff options
Diffstat (limited to 'util/xmalloc.h')
-rw-r--r-- | util/xmalloc.h | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/util/xmalloc.h b/util/xmalloc.h index 55a0b91..a4b4686 100644 --- a/util/xmalloc.h +++ b/util/xmalloc.h @@ -4,7 +4,7 @@ * The canonical version of this file is maintained in the rra-c-util package, * which can be found at <http://www.eyrie.org/~eagle/software/rra-c-util/>. * - * Copyright 2010, 2012 + * Copyright 2010, 2012, 2013, 2014 * The Board of Trustees of the Leland Stanford Junior University * Copyright (c) 2004, 2005, 2006 * by Internet Systems Consortium, Inc. ("ISC") @@ -33,7 +33,8 @@ #include <config.h> #include <portable/macros.h> -#include <sys/types.h> +#include <stdarg.h> +#include <stddef.h> /* * The functions are actually macros so that we can pick up the file and line @@ -46,6 +47,8 @@ #define xstrdup(p) x_strdup((p), __FILE__, __LINE__) #define xstrndup(p, size) x_strndup((p), (size), __FILE__, __LINE__) #define xvasprintf(p, f, a) x_vasprintf((p), (f), (a), __FILE__, __LINE__) +#define xreallocarray(p, n, size) \ + x_reallocarray((p), (n), (size), __FILE__, __LINE__) /* * asprintf is a special case since it takes variable arguments. If we have @@ -80,6 +83,8 @@ void *x_malloc(size_t, const char *, int) __attribute__((__alloc_size__(1), __malloc__, __nonnull__)); void *x_realloc(void *, size_t, const char *, int) __attribute__((__alloc_size__(2), __malloc__, __nonnull__(3))); +void *x_reallocarray(void *, size_t, size_t, const char *, int) + __attribute__((__alloc_size__(2, 3), __malloc__, __nonnull__(4))); char *x_strdup(const char *, const char *, int) __attribute__((__malloc__, __nonnull__)); char *x_strndup(const char *, size_t, const char *, int) @@ -96,7 +101,11 @@ void x_asprintf(char **, const char *, ...) __attribute__((__nonnull__, __format__(printf, 2, 3))); #endif -/* Failure handler takes the function, the size, the file, and the line. */ +/* + * Failure handler takes the function, the size, the file, and the line. The + * size will be zero if the failure was due to some failure in snprintf + * instead of a memory allocation failure. + */ typedef void (*xmalloc_handler_type)(const char *, size_t, const char *, int); /* The default error handler. */ |