[3/4] Remove weak declaration of free from <inline-hashtab.h>
Commit Message
elf/dl-minimal.c provides a definition of free, so the function
pointer is always non-null, even before the final relocation
of the loader.
---
include/inline-hashtab.h | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
Comments
On 2/8/20 2:01 PM, Florian Weimer wrote:
> elf/dl-minimal.c provides a definition of free, so the function
> pointer is always non-null, even before the final relocation
> of the loader.
Agreed.
OK for master.
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
> ---
> include/inline-hashtab.h | 11 +++--------
> 1 file changed, 3 insertions(+), 8 deletions(-)
>
> diff --git a/include/inline-hashtab.h b/include/inline-hashtab.h
> index d25bb95083..3c09978199 100644
> --- a/include/inline-hashtab.h
> +++ b/include/inline-hashtab.h
> @@ -25,8 +25,6 @@
> #ifndef INLINE_HASHTAB_H
> # define INLINE_HASHTAB_H 1
>
> -extern void weak_function free (void *ptr);
> -
OK.
> struct hashtab
> {
> /* Table itself. */
> @@ -56,8 +54,7 @@ htab_create (void)
> ht->free = free;
> if (! ht->entries)
> {
> - if (ht->free)
> - ht->free (ht);
> + free (ht);
OK.
> return NULL;
> }
>
> @@ -78,8 +75,7 @@ htab_delete (struct hashtab *htab)
> for (i = htab->size - 1; i >= 0; i--)
> free (htab->entries[i]);
>
> - if (htab->free)
> - htab->free (htab->entries);
> + htab->free (htab->entries);
OK.
> free (htab);
> }
>
> @@ -167,8 +163,7 @@ htab_expand (struct hashtab *htab, int (*hash_fn) (void *))
> allocated early as long as there's no corresponding free(), but
> this isn't so much memory as to be significant. */
>
> - if (htab->free)
> - htab->free (oentries);
> + htab->free (oentries);
OK.
>
> /* Use the free() corresponding to the malloc() above to free this
> up. */
>
@@ -25,8 +25,6 @@
#ifndef INLINE_HASHTAB_H
# define INLINE_HASHTAB_H 1
-extern void weak_function free (void *ptr);
-
struct hashtab
{
/* Table itself. */
@@ -56,8 +54,7 @@ htab_create (void)
ht->free = free;
if (! ht->entries)
{
- if (ht->free)
- ht->free (ht);
+ free (ht);
return NULL;
}
@@ -78,8 +75,7 @@ htab_delete (struct hashtab *htab)
for (i = htab->size - 1; i >= 0; i--)
free (htab->entries[i]);
- if (htab->free)
- htab->free (htab->entries);
+ htab->free (htab->entries);
free (htab);
}
@@ -167,8 +163,7 @@ htab_expand (struct hashtab *htab, int (*hash_fn) (void *))
allocated early as long as there's no corresponding free(), but
this isn't so much memory as to be significant. */
- if (htab->free)
- htab->free (oentries);
+ htab->free (oentries);
/* Use the free() corresponding to the malloc() above to free this
up. */