summaryrefslogtreecommitdiff
path: root/common/compat.h
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2017-08-08 14:52:24 +0200
committerDaiki Ueno <ueno@gnu.org>2017-08-08 16:04:40 +0200
commita860db364521ca6e9046bbf60fbbb1ca2bc08711 (patch)
tree2dc9206f1abd6a72697a3a851594cbd6bd7816b1 /common/compat.h
parent53402f9e5296718d22ddf1a77658067c2751f068 (diff)
common: Use reallocarray instead of realloc as appropriate
reallocarray is a new POSIX function added in glibc 2.26, with built-in overflow checks. Take advantage of that function for internal array allocation.
Diffstat (limited to 'common/compat.h')
-rw-r--r--common/compat.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/common/compat.h b/common/compat.h
index b021494..a9d2fe1 100644
--- a/common/compat.h
+++ b/common/compat.h
@@ -258,6 +258,14 @@ char * strndup (const char *data,
#endif /* HAVE_STRDUP */
+#ifndef HAVE_REALLOCARRAY
+
+void * reallocarray (void *ptr,
+ size_t nmemb,
+ size_t size);
+
+#endif /* HAVE_REALLOCARRAY */
+
#ifdef HAVE_STDBOOL_H
#include <stdbool.h>
#else