2021-01-08 Paul Eggert <eggert@cs.ucla.edu>
+ dynarray: work even if ‘free’ is replaced
+ Problem reported by Darshit Shah in:
+ https://lists.gnu.org/r/bug-gnulib/2021-01/msg00140.html
+ * lib/malloc/dynarray-skeleton.c (DYNARRAY_FREE): New macro.
+ Use it everywhere instead of DYNARRAY_NAME (free).
+
tempname: don’t block for minutes
Derived from a patch proposed by Adhemerval Zanella in:
https://sourceware.org/pipermail/libc-alpha/2021-January/121302.html
#define DYNARRAY_CONCAT1(prefix, name) DYNARRAY_CONCAT0(prefix, name)
#define DYNARRAY_NAME(name) DYNARRAY_CONCAT1(DYNARRAY_PREFIX, name)
+/* Use DYNARRAY_FREE instead of DYNARRAY_NAME (free),
+ so that Gnulib does not change 'free' to 'rpl_free'. */
+#define DYNARRAY_FREE DYNARRAY_CONCAT1 (DYNARRAY_NAME (f), ree)
+
/* Address of the scratch buffer if any. */
#if DYNARRAY_HAVE_SCRATCH
# define DYNARRAY_SCRATCH(list) (list)->scratch
/* Deallocate the dynamic array and its elements. */
__attribute_maybe_unused__ __nonnull ((1))
static void
-DYNARRAY_NAME (free) (struct DYNARRAY_STRUCT *list)
+DYNARRAY_FREE (struct DYNARRAY_STRUCT *list)
{
DYNARRAY_NAME (free__elements__)
(list->u.dynarray_header.array, list->u.dynarray_header.used);
else
{
/* On error, we need to free all data. */
- DYNARRAY_NAME (free) (list);
+ DYNARRAY_FREE (list);
errno = ENOMEM;
return false;
}
else
{
/* On error, we need to free all data. */
- DYNARRAY_NAME (free) (list);
+ DYNARRAY_FREE (list);
errno = ENOMEM;
return NULL;
}