summaryrefslogtreecommitdiffstats
path: root/tools/gnulib/patches/160-flag-reallocarray.patch
blob: 7c88c0de37422e44ad0956ed1161933d6405e911 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
--- a/lib/ialloc.h
+++ b/lib/ialloc.h
@@ -91,6 +91,8 @@ icalloc (idx_t n, idx_t s)
   return calloc (n, s);
 }
 
+#if GNULIB_REALLOCARRAY
+
 /* 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.  */
@@ -102,6 +104,8 @@ ireallocarray (void *p, idx_t n, idx_t s
           : _gl_alloc_nomem ());
 }
 
+#endif /* GNULIB_REALLOCARRAY */
+
 #ifdef __cplusplus
 }
 #endif
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -51,12 +51,16 @@ ximalloc (idx_t s)
   return check_nonnull (imalloc (s));
 }
 
+#if GNULIB_REALLOCARRAY
+
 char *
 xcharalloc (size_t n)
 {
   return XNMALLOC (n, char);
 }
 
+#endif /* GNULIB_REALLOCARRAY */
+
 /* Change the size of an allocated block of memory P to S bytes,
    with error checking.  */
 
@@ -75,6 +79,8 @@ xirealloc (void *p, idx_t s)
   return check_nonnull (irealloc (p, s));
 }
 
+#if GNULIB_REALLOCARRAY
+
 /* Change the size of an allocated block of memory P to an array of N
    objects each of S bytes, with error checking.  */
 
@@ -205,6 +211,8 @@ x2nrealloc (void *p, size_t *pn, size_t
   return p;
 }
 
+#endif /* GNULIB_REALLOCARRAY */
+
 /* Grow PA, which points to an array of *PN items, and return the
    location of the reallocated array, updating *PN to reflect its
    new size.  The new array will contain at least N_INCR_MIN more
--- a/lib/xalloc.h
+++ b/lib/xalloc.h
@@ -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))))
 
+# if GNULIB_REALLOCARRAY
 
 /* Allocate an array of N objects, each with S bytes of memory,
    dynamically, with error checking.  S must be nonzero.  */
@@ -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;
 
+# endif /* GNULIB_REALLOCARRAY */
+
 #endif /* GNULIB_XALLOC */
 
 
--- a/lib/safe-alloc.h
+++ b/lib/safe-alloc.h
@@ -37,7 +37,6 @@ _GL_INLINE_HEADER_BEGIN
 extern "C" {
 #endif
 
-
 /* Don't call this directly - use the macros below.  */
 _GL_ATTRIBUTE_NODISCARD SAFE_ALLOC_INLINE int
 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)))
 
+#if GNULIB_REALLOCARRAY
+
 /**
  * ALLOC_N_UNINITIALIZED:
  * @ptr: pointer to allocated memory
@@ -100,6 +101,8 @@ safe_alloc_check (void *ptr)
 #define REALLOC_N(ptr, count) \
   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 */