From b18220936c6a1c660a108b88165c1972944e51fc Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Tue, 5 Jul 2022 13:00:41 +0930 Subject: [PATCH] gas: free sy_hash, macro_hash and po_hash * 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. --- gas/macro.c | 6 ++++++ gas/macro.h | 1 + gas/output-file.c | 5 +++++ gas/read.c | 13 +++++++++++++ gas/read.h | 1 + gas/symbols.c | 6 ++++++ gas/symbols.h | 1 + 7 files changed, 33 insertions(+) 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 (); +} #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); +} #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); -- 2.30.2