public inbox for binutils-cvs@sourceware.org
help / color / mirror / Atom feed
* [binutils-gdb] dw2gencfi.c: use notes obstack
@ 2022-07-09 12:35 Alan Modra
  0 siblings, 0 replies; only message in thread
From: Alan Modra @ 2022-07-09 12:35 UTC (permalink / raw)
  To: bfd-cvs

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=5a210b9fe8a5fe616320f5adf432516334c3702f

commit 5a210b9fe8a5fe616320f5adf432516334c3702f
Author: Alan Modra <amodra@gmail.com>
Date:   Fri Jul 8 08:48:16 2022 +0930

    dw2gencfi.c: use notes obstack
    
    Use notes obstack for dwcfi_hash entries, and free table.  Freeing the
    table makes memory checkers complain more about "definitely lost"
    memory as we've moved some from the "still reachable" category.
    That will be fixed with a later patch.
    
            * dw2gencfi.c (get_debugseg_name): Allocate on notes obstack.
            (alloc_debugseg_item): Likewise.
            (dwcfi_hash_find_or_make): Adjust failure path free.
            (cfi_finish): Delete dwfci_hash.

Diff:
---
 gas/dw2gencfi.c | 22 ++++++++++------------
 1 file changed, 10 insertions(+), 12 deletions(-)

diff --git a/gas/dw2gencfi.c b/gas/dw2gencfi.c
index 961a3b92188..6be8cb50495 100644
--- a/gas/dw2gencfi.c
+++ b/gas/dw2gencfi.c
@@ -229,13 +229,10 @@ get_debugseg_name (segT seg, const char *base_name)
   const char * dollar;
   const char * dot;
 
-  if (!seg)
-    return concat (base_name, NULL);
-
-  name = bfd_section_name (seg);
-
-  if (name == NULL || *name == 0)
-    return concat (base_name, NULL);
+  if (!seg
+      || (name = bfd_section_name (seg)) == NULL
+      || *name == 0)
+    return notes_strdup (base_name);
 	
   dollar = strchr (name, '$');
   dot = strchr (name + 1, '.');
@@ -244,7 +241,7 @@ get_debugseg_name (segT seg, const char *base_name)
     {
       if (!strcmp (base_name, ".eh_frame_entry")
 	  && strcmp (name, ".text") != 0)
-	return concat (base_name, ".", name, NULL);
+	return notes_concat (base_name, ".", name, NULL);
 
       name = "";
     }
@@ -257,7 +254,7 @@ get_debugseg_name (segT seg, const char *base_name)
   else
     name = dollar;
 
-  return concat (base_name, name, NULL);
+  return notes_concat (base_name, name, NULL);
 }
 
 /* Allocate a dwcfi_seg_list structure.  */
@@ -267,8 +264,7 @@ alloc_debugseg_item (segT seg, int subseg, char *name)
 {
   struct dwcfi_seg_list *r;
 
-  r = (struct dwcfi_seg_list *)
-    xmalloc (sizeof (struct dwcfi_seg_list) + strlen (name));
+  r = notes_alloc (sizeof (*r) + strlen (name));
   r->seg = seg;
   r->subseg = subseg;
   r->seg_name = name;
@@ -351,7 +347,7 @@ dwcfi_hash_find_or_make (segT cseg, const char *base_name, int flags)
       str_hash_insert (dwcfi_hash, item->seg_name, item, 0);
     }
   else
-    free (name);
+    notes_free (name);
 
   return item;
 }
@@ -2542,6 +2538,8 @@ cfi_finish (void)
 	for (fde = all_fde_data; fde ; fde = fde->next)
 	  SET_HANDLED (fde, 0);
     }
+  if (dwcfi_hash)
+    htab_delete (dwcfi_hash);
 }
 
 #else /* TARGET_USE_CFIPOP */


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-07-09 12:35 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-09 12:35 [binutils-gdb] dw2gencfi.c: use notes obstack Alan Modra

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).