]> Savannah Git Hosting - gnulib.git/commitdiff
dynarray: work even if ‘free’ is replaced
authorPaul Eggert <eggert@cs.ucla.edu>
Sat, 9 Jan 2021 03:50:16 +0000 (19:50 -0800)
committerPaul Eggert <eggert@cs.ucla.edu>
Sat, 9 Jan 2021 03:50:52 +0000 (19:50 -0800)
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).

ChangeLog
lib/malloc/dynarray-skeleton.c

index b76330e5b6b2cfa404ac159fe3396558bff8395d..1e589aac36daf6e319f67fee93f8eadabc92f1c9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 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
index fe886102c647a48dec517ebde597bd8c20a5e4e8..5b9f37bdd67c139333813bc08030fdac450a9271 100644 (file)
@@ -150,6 +150,10 @@ struct DYNARRAY_STRUCT
 #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
@@ -200,7 +204,7 @@ DYNARRAY_NAME (init) (struct DYNARRAY_STRUCT *list)
 /* 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);
@@ -466,7 +470,7 @@ DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list,
   else
     {
       /* On error, we need to free all data.  */
-      DYNARRAY_NAME (free) (list);
+      DYNARRAY_FREE (list);
       errno = ENOMEM;
       return false;
     }
@@ -497,7 +501,7 @@ DYNARRAY_NAME (finalize) (struct DYNARRAY_STRUCT *list, size_t *lengthp)
   else
     {
       /* On error, we need to free all data.  */
-      DYNARRAY_NAME (free) (list);
+      DYNARRAY_FREE (list);
       errno = ENOMEM;
       return NULL;
     }