aboutsummaryrefslogtreecommitdiff
path: root/tools/gnulib/patches/160-flag-reallocarray.patch
blob: 8ffe273e1178595eace17dd37ac2026d9a326f77 (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
--- a/lib/ialloc.h
+++ b/lib/ialloc.h
@@ -106,6 +106,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.  */
@@ -131,6 +133,8 @@ ireallocarray (void *p, idx_t n, idx_t s
     return _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 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 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
@@ -129,6 +129,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 +157,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
@@ -36,6 +36,8 @@ _GL_INLINE_HEADER_BEGIN
 # define SAFE_ALLOC_INLINE _GL_INLINE
 #endif
 
+#if GNULIB_REALLOCARRAY
+
 /* Don't call these directly - use the macros below.  */
 SAFE_ALLOC_INLINE void *
 safe_alloc_realloc_n (void *ptr, size_t count, size_t size)
@@ -51,6 +53,9 @@ safe_alloc_realloc_n (void *ptr, size_t
 #endif
   return ptr;
 }
+
+#endif /* GNULIB_REALLOCARRAY */
+
 _GL_ATTRIBUTE_NODISCARD SAFE_ALLOC_INLINE int
 safe_alloc_check (void *ptr)
 {
@@ -84,6 +89,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
@@ -112,6 +119,8 @@ safe_alloc_check (void *ptr)
 #define REALLOC_N(ptr, count) \
   safe_alloc_check ((ptr) = safe_alloc_realloc_n (ptr, count, sizeof *(ptr)))
 
+#endif /* GNULIB_REALLOCARRAY */
+
 /**
  * FREE:
  * @ptr: pointer holding address to be freed