diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2021-01-08 19:50:16 -0800 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2021-01-08 19:50:52 -0800 |
commit | 6a00fdb4bb105697aa27ba97ef7ec33287790ad3 (patch) | |
tree | 74bef209f22d1444a7d380e7bd1a11df15bc9391 /lib | |
parent | b0ebaf83a49fe4a895a78ddf5b0c4a029e34c566 (diff) | |
download | gnulib-6a00fdb4bb105697aa27ba97ef7ec33287790ad3.tar.gz |
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).
Diffstat (limited to 'lib')
-rw-r--r-- | lib/malloc/dynarray-skeleton.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/malloc/dynarray-skeleton.c b/lib/malloc/dynarray-skeleton.c index fe886102c6..5b9f37bdd6 100644 --- a/lib/malloc/dynarray-skeleton.c +++ b/lib/malloc/dynarray-skeleton.c @@ -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; } |