public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] elf: Call bfd_malloc instead xmalloc
@ 2024-04-06  0:10 H.J. Lu
  2024-04-06 11:54 ` H.J. Lu
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 2024-04-06  0:10 UTC (permalink / raw)
  To: binutils; +Cc: amodra

	* elflink.c (elf_link_add_object_symbols): Call bfd_malloc
	instead of xmalloc.
---
 bfd/elflink.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/bfd/elflink.c b/bfd/elflink.c
index e41b3d6dad7..a427acfc37d 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -4378,12 +4378,13 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
 	{
 	  /* Initialize first_hash for an IR input.  */
 	  htab->first_hash = (struct bfd_hash_table *)
-	    xmalloc (sizeof (struct bfd_hash_table));
-	  if (!bfd_hash_table_init
-	      (htab->first_hash, elf_link_first_hash_newfunc,
-	       sizeof (struct elf_link_first_hash_entry)))
+	    bfd_malloc (sizeof (struct bfd_hash_table));
+	  if (htab->first_hash == NULL
+	      || !bfd_hash_table_init
+		   (htab->first_hash, elf_link_first_hash_newfunc,
+		    sizeof (struct elf_link_first_hash_entry)))
 	    info->callbacks->einfo
-	      (_("%F%P: first_hash failed to initialize: %E\n"));
+	      (_("%F%P: first_hash failed to create: %E\n"));
 	}
     }
   else
-- 
2.44.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] elf: Call bfd_malloc instead xmalloc
  2024-04-06  0:10 [PATCH] elf: Call bfd_malloc instead xmalloc H.J. Lu
@ 2024-04-06 11:54 ` H.J. Lu
  0 siblings, 0 replies; 2+ messages in thread
From: H.J. Lu @ 2024-04-06 11:54 UTC (permalink / raw)
  To: binutils; +Cc: amodra

On Fri, Apr 5, 2024 at 5:10 PM H.J. Lu <hjl.tools@gmail.com> wrote:
>
>         * elflink.c (elf_link_add_object_symbols): Call bfd_malloc
>         instead of xmalloc.
> ---
>  bfd/elflink.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/bfd/elflink.c b/bfd/elflink.c
> index e41b3d6dad7..a427acfc37d 100644
> --- a/bfd/elflink.c
> +++ b/bfd/elflink.c
> @@ -4378,12 +4378,13 @@ elf_link_add_object_symbols (bfd *abfd, struct bfd_link_info *info)
>         {
>           /* Initialize first_hash for an IR input.  */
>           htab->first_hash = (struct bfd_hash_table *)
> -           xmalloc (sizeof (struct bfd_hash_table));
> -         if (!bfd_hash_table_init
> -             (htab->first_hash, elf_link_first_hash_newfunc,
> -              sizeof (struct elf_link_first_hash_entry)))
> +           bfd_malloc (sizeof (struct bfd_hash_table));
> +         if (htab->first_hash == NULL
> +             || !bfd_hash_table_init
> +                  (htab->first_hash, elf_link_first_hash_newfunc,
> +                   sizeof (struct elf_link_first_hash_entry)))
>             info->callbacks->einfo
> -             (_("%F%P: first_hash failed to initialize: %E\n"));
> +             (_("%F%P: first_hash failed to create: %E\n"));
>         }
>      }
>    else
> --
> 2.44.0
>

I am checking it in.

-- 
H.J.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-04-06 11:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-04-06  0:10 [PATCH] elf: Call bfd_malloc instead xmalloc H.J. Lu
2024-04-06 11:54 ` H.J. Lu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).