public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Alan Modra <amodra@gmail.com>
To: binutils@sourceware.org
Subject: gas: free sy_hash, macro_hash and po_hash
Date: Sat, 9 Jul 2022 21:59:07 +0930	[thread overview]
Message-ID: <Ysl0kzXyHuC3D2eK@squeak.grove.modra.org> (raw)

	* macro.c (macro_end): New function.
	* macro.h (macro_end): Declare.
	* read.c (read_end, poend): New functions.
	* read.h (read_end): Declare.
	* symbols.c (symbol_end): New function.
	* symbols.h (symbol_end): Declare.
	* output-file.c (output_file_close): Call new *_end functions.

diff --git a/gas/macro.c b/gas/macro.c
index b360b2ec038..e2cfbee5439 100644
--- a/gas/macro.c
+++ b/gas/macro.c
@@ -84,6 +84,12 @@ macro_init (int alternate, int mri, int strip_at,
   macro_expr = exp;
 }
 
+void
+macro_end (void)
+{
+  htab_delete (macro_hash);
+}
+
 /* Switch in and out of alternate mode on the fly.  */
 
 void
diff --git a/gas/macro.h b/gas/macro.h
index 227c9cb5c93..03d6a81c5e3 100644
--- a/gas/macro.h
+++ b/gas/macro.h
@@ -85,6 +85,7 @@ extern int buffer_and_nest (const char *, const char *, sb *,
 			    size_t (*) (sb *));
 extern void macro_init (int, int, int,
 			size_t (*) (const char *, size_t, sb *, offsetT *));
+extern void macro_end (void);
 extern void macro_set_alternate (int);
 extern void macro_mri_mode (int);
 extern const char *define_macro (size_t, sb *, sb *, size_t (*) (sb *),
diff --git a/gas/output-file.c b/gas/output-file.c
index 584deb27c08..3c4074b263d 100644
--- a/gas/output-file.c
+++ b/gas/output-file.c
@@ -20,6 +20,8 @@
 
 #include "as.h"
 #include "subsegs.h"
+#include "sb.h"
+#include "macro.h"
 #include "output-file.h"
 
 #ifndef TARGET_MACH
@@ -103,6 +105,9 @@ output_file_close (void)
   if (!keep_it && filename)
     unlink_if_ordinary (filename);
 
+  macro_end ();
+  read_end ();
+  symbol_end ();
   subsegs_end (obs);
 
   if (!res)
diff --git a/gas/read.c b/gas/read.c
index 2f9a22a8d76..edf3f2a7881 100644
--- a/gas/read.c
+++ b/gas/read.c
@@ -248,6 +248,7 @@ static void s_reloc (int);
 static int hex_float (int, char *);
 static segT get_known_segmented_expression (expressionS * expP);
 static void pobegin (void);
+static void poend (void);
 static size_t get_non_macro_line_sb (sb *);
 static void generate_file_debug (void);
 static char *_find_end_of_line (char *, int, int, int);
@@ -276,6 +277,12 @@ read_begin (void)
   if (flag_mri)
     lex_type['?'] = 3;
 }
+
+void
+read_end (void)
+{
+  poend ();
+}
 \f
 #ifndef TC_ADDRESS_BYTES
 #define TC_ADDRESS_BYTES address_bytes
@@ -561,6 +568,12 @@ pobegin (void)
   pop_override_ok = 1;
   cfi_pop_insert ();
 }
+
+static void
+poend (void)
+{
+  htab_delete (po_hash);
+}
 \f
 #define HANDLE_CONDITIONAL_ASSEMBLY(num_read)				\
   if (ignore_input ())							\
diff --git a/gas/read.h b/gas/read.h
index 0fa9e795189..acab6674899 100644
--- a/gas/read.h
+++ b/gas/read.h
@@ -141,6 +141,7 @@ extern unsigned output_leb128 (char *, valueT, int);
 extern void pseudo_set (symbolS * symbolP);
 extern void read_a_source_file (const char *name);
 extern void read_begin (void);
+extern void read_end (void);
 extern void read_print_statistics (FILE *);
 extern char *read_symbol_name (void);
 extern unsigned sizeof_leb128 (valueT, int);
diff --git a/gas/symbols.c b/gas/symbols.c
index 00ae49b91ed..744f6e1260f 100644
--- a/gas/symbols.c
+++ b/gas/symbols.c
@@ -3062,6 +3062,12 @@ symbol_begin (void)
     fb_label_init ();
 }
 
+void
+symbol_end (void)
+{
+  htab_delete (sy_hash);
+}
+
 void
 dot_symbol_init (void)
 {
diff --git a/gas/symbols.h b/gas/symbols.h
index 240e08f8df6..c33a28ff86b 100644
--- a/gas/symbols.h
+++ b/gas/symbols.h
@@ -67,6 +67,7 @@ symbolS *symbol_temp_make (void);
 symbolS *colon (const char *sym_name);
 void local_colon (int n);
 void symbol_begin (void);
+void symbol_end (void);
 void dot_symbol_init (void);
 void symbol_print_statistics (FILE *);
 void symbol_table_insert (symbolS * symbolP);

-- 
Alan Modra
Australia Development Lab, IBM

                 reply	other threads:[~2022-07-09 12:29 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Ysl0kzXyHuC3D2eK@squeak.grove.modra.org \
    --to=amodra@gmail.com \
    --cc=binutils@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).