|
|
@@ -1,6 +1,6 @@
|
|
|
--- a/lib/ialloc.h
|
|
|
+++ b/lib/ialloc.h
|
|
|
-@@ -106,6 +106,8 @@ icalloc (idx_t n, idx_t s)
|
|
|
+@@ -91,6 +91,8 @@ icalloc (idx_t n, idx_t s)
|
|
|
return calloc (n, s);
|
|
|
}
|
|
|
|
|
|
@@ -9,8 +9,8 @@
|
|
|
/* ireallocarray (ptr, num, size) is like reallocarray (ptr, num, size).
|
|
|
It returns a non-NULL pointer to num * size bytes of memory.
|
|
|
Upon failure, it returns NULL with errno set. */
|
|
|
-@@ -131,6 +133,8 @@ ireallocarray (void *p, idx_t n, idx_t s
|
|
|
- return _gl_alloc_nomem ();
|
|
|
+@@ -102,6 +104,8 @@ ireallocarray (void *p, idx_t n, idx_t s
|
|
|
+ : _gl_alloc_nomem ());
|
|
|
}
|
|
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
|
@@ -57,7 +57,24 @@
|
|
|
new size. The new array will contain at least N_INCR_MIN more
|
|
|
--- a/lib/xalloc.h
|
|
|
+++ b/lib/xalloc.h
|
|
|
-@@ -129,6 +129,7 @@ char *xstrdup (char const *str)
|
|
|
+@@ -81,10 +81,16 @@ void *xrealloc (void *p, size_t s)
|
|
|
+ _GL_ATTRIBUTE_ALLOC_SIZE ((2));
|
|
|
+ void *xirealloc (void *p, idx_t s)
|
|
|
+ _GL_ATTRIBUTE_ALLOC_SIZE ((2)) _GL_ATTRIBUTE_RETURNS_NONNULL;
|
|
|
++
|
|
|
++# if GNULIB_REALLOCARRAY
|
|
|
++
|
|
|
+ void *xreallocarray (void *p, size_t n, size_t s)
|
|
|
+ _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3));
|
|
|
+ void *xireallocarray (void *p, idx_t n, idx_t s)
|
|
|
+ _GL_ATTRIBUTE_ALLOC_SIZE ((2, 3)) _GL_ATTRIBUTE_RETURNS_NONNULL;
|
|
|
++
|
|
|
++# endif /* GNULIB_REALLOCARRAY */
|
|
|
++
|
|
|
+ void *x2realloc (void *p, size_t *ps) /* superseded by xpalloc */
|
|
|
+ _GL_ATTRIBUTE_RETURNS_NONNULL;
|
|
|
+ void *x2nrealloc (void *p, size_t *pn, size_t s) /* superseded by xpalloc */
|
|
|
+@@ -129,6 +135,7 @@ char *xstrdup (char const *str)
|
|
|
# define XCALLOC(n, t) \
|
|
|
((t *) (sizeof (t) == 1 ? xzalloc (n) : xcalloc (n, sizeof (t))))
|
|
|
|
|
|
@@ -65,7 +82,7 @@
|
|
|
|
|
|
/* Allocate an array of N objects, each with S bytes of memory,
|
|
|
dynamically, with error checking. S must be nonzero. */
|
|
|
-@@ -156,6 +157,8 @@ char *xcharalloc (size_t n)
|
|
|
+@@ -156,6 +163,8 @@ char *xcharalloc (size_t n)
|
|
|
_GL_ATTRIBUTE_MALLOC _GL_ATTRIBUTE_DEALLOC_FREE
|
|
|
_GL_ATTRIBUTE_ALLOC_SIZE ((1)) _GL_ATTRIBUTE_RETURNS_NONNULL;
|
|
|
|
|
|
@@ -76,25 +93,15 @@
|
|
|
|
|
|
--- a/lib/safe-alloc.h
|
|
|
+++ b/lib/safe-alloc.h
|
|
|
-@@ -40,6 +40,7 @@ _GL_INLINE_HEADER_BEGIN
|
|
|
+@@ -37,7 +37,6 @@ _GL_INLINE_HEADER_BEGIN
|
|
|
extern "C" {
|
|
|
#endif
|
|
|
|
|
|
-+#if GNULIB_REALLOCARRAY
|
|
|
-
|
|
|
- /* Don't call these directly - use the macros below. */
|
|
|
- SAFE_ALLOC_INLINE void *
|
|
|
-@@ -56,6 +57,9 @@ safe_alloc_realloc_n (void *ptr, size_t
|
|
|
- #endif
|
|
|
- return ptr;
|
|
|
- }
|
|
|
-+
|
|
|
-+#endif /* GNULIB_REALLOCARRAY */
|
|
|
-+
|
|
|
+-
|
|
|
+ /* Don't call this directly - use the macros below. */
|
|
|
_GL_ATTRIBUTE_NODISCARD SAFE_ALLOC_INLINE int
|
|
|
safe_alloc_check (void *ptr)
|
|
|
- {
|
|
|
-@@ -89,6 +93,8 @@ safe_alloc_check (void *ptr)
|
|
|
+@@ -72,6 +71,8 @@ safe_alloc_check (void *ptr)
|
|
|
#define ALLOC_N(ptr, count) \
|
|
|
safe_alloc_check ((ptr) = calloc (count, sizeof *(ptr)))
|
|
|
|
|
|
@@ -103,12 +110,85 @@
|
|
|
/**
|
|
|
* ALLOC_N_UNINITIALIZED:
|
|
|
* @ptr: pointer to allocated memory
|
|
|
-@@ -117,6 +123,8 @@ safe_alloc_check (void *ptr)
|
|
|
+@@ -100,6 +101,8 @@ safe_alloc_check (void *ptr)
|
|
|
#define REALLOC_N(ptr, count) \
|
|
|
- safe_alloc_check ((ptr) = safe_alloc_realloc_n (ptr, count, sizeof *(ptr)))
|
|
|
+ safe_alloc_check ((ptr) = reallocarray (ptr, count, sizeof *(ptr)))
|
|
|
|
|
|
+#endif /* GNULIB_REALLOCARRAY */
|
|
|
+
|
|
|
/**
|
|
|
* FREE:
|
|
|
* @ptr: pointer holding address to be freed
|
|
|
+--- a/lib/dfa.c
|
|
|
++++ b/lib/dfa.c
|
|
|
+@@ -1620,6 +1620,8 @@ lex (struct dfa *dfa)
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
++#if GNULIB_REALLOCARRAY
|
|
|
++
|
|
|
+ static void
|
|
|
+ addtok_mb (struct dfa *dfa, token t, char mbprop)
|
|
|
+ {
|
|
|
+@@ -1674,6 +1676,8 @@ addtok_mb (struct dfa *dfa, token t, cha
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
++#endif /* GNULIB_REALLOCARRAY */
|
|
|
++
|
|
|
+ static void addtok_wc (struct dfa *dfa, wint_t wc);
|
|
|
+
|
|
|
+ /* Add the given token to the parse tree, maintaining the depth count and
|
|
|
+@@ -2934,6 +2938,8 @@ dfaanalyze (struct dfa *d, bool searchfl
|
|
|
+ free (tmp.elems);
|
|
|
+ }
|
|
|
+
|
|
|
++#if GNULIB_REALLOCARRAY
|
|
|
++
|
|
|
+ /* Make sure D's state arrays are large enough to hold NEW_STATE. */
|
|
|
+ static void
|
|
|
+ realloc_trans_if_necessary (struct dfa *d)
|
|
|
+@@ -2969,6 +2975,8 @@ realloc_trans_if_necessary (struct dfa *
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
++#endif /* GNULIB_REALLOCARRAY */
|
|
|
++
|
|
|
+ /*
|
|
|
+ Calculate the transition table for a new state derived from state s
|
|
|
+ for a compiled dfa d after input character uc, and return the new
|
|
|
+@@ -4010,6 +4018,8 @@ freelist (char **cpp)
|
|
|
+ free (*cpp++);
|
|
|
+ }
|
|
|
+
|
|
|
++#if GNULIB_REALLOCARRAY
|
|
|
++
|
|
|
+ static char **
|
|
|
+ enlistnew (char **cpp, char *new)
|
|
|
+ {
|
|
|
+@@ -4046,6 +4056,8 @@ enlist (char **cpp, char const *str, idx
|
|
|
+ return enlistnew (cpp, ximemdup0 (str, len));
|
|
|
+ }
|
|
|
+
|
|
|
++#endif /* GNULIB_REALLOCARRAY */
|
|
|
++
|
|
|
+ /* Given pointers to two strings, return a pointer to an allocated
|
|
|
+ list of their distinct common substrings. */
|
|
|
+ static char **
|
|
|
+--- a/lib/readtokens.c
|
|
|
++++ b/lib/readtokens.c
|
|
|
+@@ -128,6 +128,8 @@ readtoken (FILE *stream,
|
|
|
+ return i;
|
|
|
+ }
|
|
|
+
|
|
|
++#if GNULIB_REALLOCARRAY
|
|
|
++
|
|
|
+ /* Build a NULL-terminated array of pointers to tokens
|
|
|
+ read from STREAM. Return the number of tokens read.
|
|
|
+ All storage is obtained through calls to xmalloc-like functions.
|
|
|
+@@ -190,3 +192,5 @@ readtokens (FILE *stream,
|
|
|
+ free (lengths);
|
|
|
+ return n_tokens;
|
|
|
+ }
|
|
|
++
|
|
|
++#endif /* GNULIB_REALLOCARRAY */
|