From: Akim Demaille Date: Tue, 12 Nov 2002 07:55:55 +0000 (+0000) Subject: * src/symtab.c (symbol_free): Remove dead deactivated code: X-Git-Tag: BISON-1_875~297 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/3e6656f9ab66ae7e629f8e5d5b41810bf070f09d?hp=ccdb39e0a6f95cb4a3f19c08885a7c421cdebedb * src/symtab.c (symbol_free): Remove dead deactivated code: type_name are properly removed. Don't use XFREE to free items that cannot be NULL. * src/struniq.h, src/struniq.c: New. * src/main.c (main): Initialize/free struniqs. * src/parse-gram.y (%union): Add astruniq member. (yyprint): Adjust. * src/scan-gram.l (<{tag}>): Return a struniq. Free the obstack bit that used to store it. * src/symtab.h (symbol_t): The 'type_name' member is a struniq. --- diff --git a/ChangeLog b/ChangeLog index ffc64985..20d8cd18 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2002-11-12 Akim Demaille + + * src/symtab.c (symbol_free): Remove dead deactivated code: + type_name are properly removed. + Don't use XFREE to free items that cannot be NULL. + * src/struniq.h, src/struniq.c: New. + * src/main.c (main): Initialize/free struniqs. + * src/parse-gram.y (%union): Add astruniq member. + (yyprint): Adjust. + * src/scan-gram.l (<{tag}>): Return a struniq. + Free the obstack bit that used to store it. + * src/symtab.h (symbol_t): The 'type_name' member is a struniq. + 2002-11-11 Paul Eggert Revamp to fix many (but not all) of the C- and M4-related quoting diff --git a/src/Makefile.am b/src/Makefile.am index 7a388a06..58833818 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -55,6 +55,7 @@ bison_SOURCES = \ scan-gram.l \ scan-skel.l \ state.c state.h \ + struniq.c struniq.h \ symlist.c symlist.h \ symtab.c symtab.h \ system.h \ diff --git a/src/main.c b/src/main.c index 04957a2b..f86bfda9 100644 --- a/src/main.c +++ b/src/main.c @@ -24,6 +24,7 @@ #include "bitset_stats.h" #include "bitset.h" #include "getargs.h" +#include "struniq.h" #include "symtab.h" #include "gram.h" #include "files.h" @@ -63,6 +64,7 @@ main (int argc, char *argv[]) if (trace_flag & trace_bitsets) bitset_stats_enable (); + struniqs_new (); muscle_init (); /* Read the input. Copy some parts of it to FGUARD, FACTION, FTABLE @@ -165,6 +167,7 @@ main (int argc, char *argv[]) contains things such as user actions, prologue, epilogue etc. */ scanner_free (); muscle_free (); + struniqs_free (); /* If using alloca.c, flush the alloca'ed memory for the benefit of people running Bison as a library in IDEs. */ #if C_ALLOCA diff --git a/src/parse-gram.c b/src/parse-gram.c index 27596094..69ef7ebc 100644 --- a/src/parse-gram.c +++ b/src/parse-gram.c @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 1.75b. */ +/* A Bison parser, made from parse-gram.y, by GNU bison 1.75b. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. @@ -236,9 +236,10 @@ typedef union { int integer; char *string; assoc_t assoc; + struniq_t struniq; } yystype; -/* Line 212 of /tmp/prefix/share/bison/yacc.c. */ -#line 241 "parse-gram.c" +/* Line 237 of /usr/local/share/bison/yacc.c. */ +#line 243 "parse-gram.c" # define YYSTYPE yystype # define YYSTYPE_IS_TRIVIAL 1 #endif @@ -258,8 +259,8 @@ typedef struct yyltype /* Copy the second part of user declarations. */ -/* Line 232 of /tmp/prefix/share/bison/yacc.c. */ -#line 262 "parse-gram.c" +/* Line 257 of /usr/local/share/bison/yacc.c. */ +#line 264 "parse-gram.c" #if ! defined (yyoverflow) || YYERROR_VERBOSE @@ -457,14 +458,14 @@ static const yysigned_char yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const unsigned short yyrline[] = { - 0, 167, 167, 180, 182, 185, 187, 188, 189, 190, - 191, 192, 193, 194, 195, 197, 198, 199, 200, 201, - 203, 204, 205, 206, 207, 210, 212, 213, 217, 224, - 223, 234, 233, 246, 245, 251, 251, 256, 265, 280, - 282, 283, 286, 288, 293, 295, 299, 304, 309, 315, - 321, 331, 334, 343, 345, 351, 353, 358, 365, 364, - 369, 371, 374, 377, 379, 381, 383, 385, 389, 391, - 394, 400, 409, 417, 422, 428, 430 + 0, 168, 168, 181, 183, 186, 188, 189, 190, 191, + 192, 193, 194, 195, 196, 198, 199, 200, 201, 202, + 204, 205, 206, 207, 208, 211, 213, 214, 218, 225, + 224, 235, 234, 247, 246, 252, 252, 257, 266, 281, + 283, 284, 287, 289, 294, 296, 300, 305, 310, 316, + 322, 332, 335, 344, 346, 352, 354, 359, 366, 365, + 370, 372, 375, 378, 380, 382, 384, 386, 390, 392, + 395, 401, 410, 418, 423, 429, 431 }; #endif @@ -1215,7 +1216,7 @@ yyreduce: switch (yyn) { case 2: -#line 169 "parse-gram.y" +#line 170 "parse-gram.y" { yycontrol->errcode = 0; epilogue_set (yyvsp[0].string, yylsp[0]); @@ -1223,109 +1224,109 @@ yyreduce: break; case 6: -#line 187 "parse-gram.y" +#line 188 "parse-gram.y" { prologue_augment (yyvsp[0].string, yylsp[0]); } break; case 7: -#line 188 "parse-gram.y" +#line 189 "parse-gram.y" { debug_flag = 1; } break; case 8: -#line 189 "parse-gram.y" +#line 190 "parse-gram.y" { muscle_insert (yyvsp[-1].string, yyvsp[0].string); } break; case 9: -#line 190 "parse-gram.y" +#line 191 "parse-gram.y" { defines_flag = 1; } break; case 10: -#line 191 "parse-gram.y" +#line 192 "parse-gram.y" { error_verbose = 1; } break; case 11: -#line 192 "parse-gram.y" +#line 193 "parse-gram.y" { expected_conflicts = yyvsp[0].integer; } break; case 12: -#line 193 "parse-gram.y" +#line 194 "parse-gram.y" { spec_file_prefix = yyvsp[0].string; } break; case 13: -#line 194 "parse-gram.y" +#line 195 "parse-gram.y" { glr_parser = 1; } break; case 14: -#line 196 "parse-gram.y" +#line 197 "parse-gram.y" { muscle_pair_list_grow ("lex_param", yyvsp[-2].string, yyvsp[0].string); } break; case 15: -#line 197 "parse-gram.y" +#line 198 "parse-gram.y" { locations_flag = 1; } break; case 16: -#line 198 "parse-gram.y" +#line 199 "parse-gram.y" { spec_name_prefix = yyvsp[0].string; } break; case 17: -#line 199 "parse-gram.y" +#line 200 "parse-gram.y" { no_lines_flag = 1; } break; case 18: -#line 200 "parse-gram.y" +#line 201 "parse-gram.y" { spec_outfile = yyvsp[0].string; } break; case 19: -#line 202 "parse-gram.y" +#line 203 "parse-gram.y" { muscle_pair_list_grow ("parse_param", yyvsp[-2].string, yyvsp[0].string); } break; case 20: -#line 203 "parse-gram.y" +#line 204 "parse-gram.y" { pure_parser = 1; } break; case 21: -#line 204 "parse-gram.y" +#line 205 "parse-gram.y" { skeleton = yyvsp[0].string; } break; case 22: -#line 205 "parse-gram.y" +#line 206 "parse-gram.y" { token_table_flag = 1; } break; case 23: -#line 206 "parse-gram.y" +#line 207 "parse-gram.y" { report_flag = 1; } break; case 24: -#line 207 "parse-gram.y" +#line 208 "parse-gram.y" { yacc_flag = 1; } break; case 27: -#line 214 "parse-gram.y" +#line 215 "parse-gram.y" { grammar_start_symbol_set (yyvsp[0].symbol, yylsp[0]); } break; case 28: -#line 218 "parse-gram.y" +#line 219 "parse-gram.y" { typed = 1; MUSCLE_INSERT_INT ("stype_line", yylsp[0].first_line); @@ -1334,12 +1335,12 @@ yyreduce: break; case 29: -#line 224 "parse-gram.y" +#line 225 "parse-gram.y" { current_braced_code = destructor_braced_code; } break; case 30: -#line 226 "parse-gram.y" +#line 227 "parse-gram.y" { symbol_list_t *list; for (list = yyvsp[0].list; list; list = list->next) @@ -1350,12 +1351,12 @@ yyreduce: break; case 31: -#line 234 "parse-gram.y" +#line 235 "parse-gram.y" { current_braced_code = printer_braced_code; } break; case 32: -#line 236 "parse-gram.y" +#line 237 "parse-gram.y" { symbol_list_t *list; for (list = yyvsp[0].list; list; list = list->next) @@ -1366,12 +1367,12 @@ yyreduce: break; case 33: -#line 246 "parse-gram.y" +#line 247 "parse-gram.y" { current_class = nterm_sym; } break; case 34: -#line 247 "parse-gram.y" +#line 248 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -1379,12 +1380,12 @@ yyreduce: break; case 35: -#line 251 "parse-gram.y" +#line 252 "parse-gram.y" { current_class = token_sym; } break; case 36: -#line 252 "parse-gram.y" +#line 253 "parse-gram.y" { current_class = unknown_sym; current_type = NULL; @@ -1392,7 +1393,7 @@ yyreduce: break; case 37: -#line 257 "parse-gram.y" +#line 258 "parse-gram.y" { symbol_list_t *list; for (list = yyvsp[0].list; list; list = list->next) @@ -1402,7 +1403,7 @@ yyreduce: break; case 38: -#line 267 "parse-gram.y" +#line 268 "parse-gram.y" { symbol_list_t *list; ++current_prec; @@ -1417,49 +1418,49 @@ yyreduce: break; case 39: -#line 281 "parse-gram.y" +#line 282 "parse-gram.y" { yyval.assoc = left_assoc; } break; case 40: -#line 282 "parse-gram.y" +#line 283 "parse-gram.y" { yyval.assoc = right_assoc; } break; case 41: -#line 283 "parse-gram.y" +#line 284 "parse-gram.y" { yyval.assoc = non_assoc; } break; case 42: -#line 287 "parse-gram.y" +#line 288 "parse-gram.y" { current_type = NULL; } break; case 43: -#line 288 "parse-gram.y" +#line 289 "parse-gram.y" { current_type = yyvsp[0].string; } break; case 44: -#line 294 "parse-gram.y" +#line 295 "parse-gram.y" { yyval.list = symbol_list_new (yyvsp[0].symbol, yylsp[0]); } break; case 45: -#line 295 "parse-gram.y" +#line 296 "parse-gram.y" { yyval.list = symbol_list_prepend (yyvsp[-1].list, yyvsp[0].symbol, yylsp[0]); } break; case 46: -#line 301 "parse-gram.y" +#line 302 "parse-gram.y" { current_type = yyvsp[0].string; } break; case 47: -#line 305 "parse-gram.y" +#line 306 "parse-gram.y" { symbol_class_set (yyvsp[0].symbol, current_class, yylsp[0]); symbol_type_set (yyvsp[0].symbol, current_type, yylsp[0]); @@ -1467,7 +1468,7 @@ yyreduce: break; case 48: -#line 310 "parse-gram.y" +#line 311 "parse-gram.y" { symbol_class_set (yyvsp[-1].symbol, current_class, yylsp[-1]); symbol_type_set (yyvsp[-1].symbol, current_type, yylsp[-1]); @@ -1476,7 +1477,7 @@ yyreduce: break; case 49: -#line 316 "parse-gram.y" +#line 317 "parse-gram.y" { symbol_class_set (yyvsp[-1].symbol, current_class, yylsp[-1]); symbol_type_set (yyvsp[-1].symbol, current_type, yylsp[-1]); @@ -1485,7 +1486,7 @@ yyreduce: break; case 50: -#line 322 "parse-gram.y" +#line 323 "parse-gram.y" { symbol_class_set (yyvsp[-2].symbol, current_class, yylsp[-2]); symbol_type_set (yyvsp[-2].symbol, current_type, yylsp[-2]); @@ -1495,17 +1496,17 @@ yyreduce: break; case 51: -#line 333 "parse-gram.y" +#line 334 "parse-gram.y" {;} break; case 52: -#line 335 "parse-gram.y" +#line 336 "parse-gram.y" {;} break; case 56: -#line 354 "parse-gram.y" +#line 355 "parse-gram.y" { if (yacc_flag) complain_at (yyloc, _("POSIX forbids declarations in the grammar")); @@ -1513,79 +1514,79 @@ yyreduce: break; case 57: -#line 359 "parse-gram.y" +#line 360 "parse-gram.y" { yyerrok; } break; case 58: -#line 365 "parse-gram.y" +#line 366 "parse-gram.y" { current_lhs = yyvsp[-1].symbol; current_lhs_location = yylsp[-1]; } break; case 59: -#line 366 "parse-gram.y" +#line 367 "parse-gram.y" {;} break; case 60: -#line 370 "parse-gram.y" +#line 371 "parse-gram.y" { grammar_rule_end (yylsp[0]); } break; case 61: -#line 371 "parse-gram.y" +#line 372 "parse-gram.y" { grammar_rule_end (yylsp[0]); } break; case 62: -#line 376 "parse-gram.y" +#line 377 "parse-gram.y" { grammar_rule_begin (current_lhs, current_lhs_location); } break; case 63: -#line 378 "parse-gram.y" +#line 379 "parse-gram.y" { grammar_current_rule_symbol_append (yyvsp[0].symbol, yylsp[0]); } break; case 64: -#line 380 "parse-gram.y" +#line 381 "parse-gram.y" { grammar_current_rule_action_append (yyvsp[0].string, yylsp[0]); } break; case 65: -#line 382 "parse-gram.y" +#line 383 "parse-gram.y" { grammar_current_rule_prec_set (yyvsp[0].symbol, yylsp[0]); } break; case 66: -#line 384 "parse-gram.y" +#line 385 "parse-gram.y" { grammar_current_rule_dprec_set (yyvsp[0].integer, yylsp[0]); } break; case 67: -#line 386 "parse-gram.y" +#line 387 "parse-gram.y" { grammar_current_rule_merge_set (yyvsp[0].string, yylsp[0]); } break; case 68: -#line 390 "parse-gram.y" +#line 391 "parse-gram.y" { yyval.symbol = yyvsp[0].symbol; } break; case 69: -#line 391 "parse-gram.y" +#line 392 "parse-gram.y" { yyval.symbol = yyvsp[0].symbol; } break; case 70: -#line 396 "parse-gram.y" +#line 397 "parse-gram.y" { yyval.string = yyvsp[0].string; } break; case 71: -#line 402 "parse-gram.y" +#line 403 "parse-gram.y" { yyval.symbol = symbol_get (yyvsp[0].string, yylsp[0]); symbol_class_set (yyval.symbol, token_sym, yylsp[0]); @@ -1593,7 +1594,7 @@ yyreduce: break; case 72: -#line 411 "parse-gram.y" +#line 412 "parse-gram.y" { yyval.string = yyvsp[0].string + 1; yyval.string[strlen (yyval.string) - 1] = '\0'; @@ -1601,14 +1602,14 @@ yyreduce: break; case 73: -#line 419 "parse-gram.y" +#line 420 "parse-gram.y" { yyval.string = xstrdup (""); } break; case 74: -#line 423 "parse-gram.y" +#line 424 "parse-gram.y" { yyval.string = yyvsp[0].string; } @@ -1617,8 +1618,8 @@ yyreduce: } -/* Line 1031 of /tmp/prefix/share/bison/yacc.c. */ -#line 1621 "parse-gram.c" +/* Line 1056 of /usr/local/share/bison/yacc.c. */ +#line 1623 "parse-gram.c" yyvsp -= yylen; yyssp -= yylen; @@ -1837,7 +1838,7 @@ yyreturn: } -#line 432 "parse-gram.y" +#line 433 "parse-gram.y" /*------------------------------------------------------------------. | When debugging the parser, display tokens' locations and values. | @@ -1863,7 +1864,7 @@ yyprint (FILE *file, break; case TYPE: - fprintf (file, " = <%s>", value->string); + fprintf (file, " = <%s>", value->struniq); break; case BRACED_CODE: diff --git a/src/parse-gram.h b/src/parse-gram.h index ea92cb3a..96ee3d74 100644 --- a/src/parse-gram.h +++ b/src/parse-gram.h @@ -1,4 +1,4 @@ -/* A Bison parser, made by GNU Bison 1.75b. */ +/* A Bison parser, made from parse-gram.y, by GNU bison 1.75b. */ /* Skeleton parser for Yacc-like parsing with Bison, Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc. @@ -23,6 +23,9 @@ This special exception was added by the Free Software Foundation in version 1.24 of Bison. */ +#ifndef BISON_PARSE_GRAM_H +# define BISON_PARSE_GRAM_H + /* Tokens. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE @@ -133,11 +136,11 @@ typedef union { int integer; char *string; assoc_t assoc; + struniq_t struniq; } yystype; -/* Line 1293 of /tmp/prefix/share/bison/yacc.c. */ -#line 138 "y.tab.h" +/* Line 1321 of /usr/local/share/bison/yacc.c. */ +#line 143 "y.tab.h" # define YYSTYPE yystype -# define YYSTYPE_IS_TRIVIAL 1 #endif @@ -155,4 +158,5 @@ typedef struct yyltype +#endif /* not BISON_PARSE_GRAM_H */ diff --git a/src/parse-gram.y b/src/parse-gram.y index aa307881..70356942 100644 --- a/src/parse-gram.y +++ b/src/parse-gram.y @@ -92,6 +92,7 @@ braced_code_t current_braced_code = action_braced_code; int integer; char *string; assoc_t assoc; + struniq_t struniq; }; /* Define the tokens together with their human representation. */ @@ -454,7 +455,7 @@ yyprint (FILE *file, break; case TYPE: - fprintf (file, " = <%s>", value->string); + fprintf (file, " = <%s>", value->struniq); break; case BRACED_CODE: diff --git a/src/reader.c b/src/reader.c index e6b74764..64601e34 100644 --- a/src/reader.c +++ b/src/reader.c @@ -99,7 +99,7 @@ epilogue_set (const char *epilogue, location_t location) - /*-------------------------------------------------------------------. +/*-------------------------------------------------------------------. | Return the merger index for a merging function named NAME, whose | | arguments have type TYPE. Records the function, if new, in | | merger_list. | diff --git a/src/scan-gram.l b/src/scan-gram.l index 8f18c355..da92baaf 100644 --- a/src/scan-gram.l +++ b/src/scan-gram.l @@ -27,6 +27,7 @@ #include "mbswidth.h" #include "complain.h" #include "quote.h" +#include "struniq.h" #include "getargs.h" #include "gram.h" #include "reader.h" @@ -301,7 +302,8 @@ splice (\\[ \f\t\v]*\n)* "<"{tag}">" { obstack_grow (&string_obstack, yytext + 1, yyleng - 2); YY_OBS_FINISH; - yylval->string = last_string; + yylval->struniq = struniq_new (last_string); + YY_OBS_FREE; return TYPE; } diff --git a/src/struniq.c b/src/struniq.c new file mode 100644 index 00000000..4260a70f --- /dev/null +++ b/src/struniq.c @@ -0,0 +1,134 @@ +/* Keeping a unique copy of strings. + Copyright (C) 2002 Free Software Foundation, Inc. + + This file is part of Bison, the GNU Compiler Compiler. + + Bison is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Bison is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bison; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#include "system.h" +#include "quotearg.h" +#include "hash.h" +#include "struniq.h" + +/*-----------------------. +| A struniq hash table. | +`-----------------------*/ + +/* Initial capacity of struniq hash table. */ +#define HT_INITIAL_CAPACITY 257 + +static struct hash_table *struniqs_table = NULL; + +/*-------------------------------------. +| Create the struniq for S if needed. | +`-------------------------------------*/ + +const struniq_t +struniq_new (const char *s) +{ + /* Keep the struniqs in a printable form. */ + struniq_t res = hash_lookup (struniqs_table, + quotearg_style (escape_quoting_style, s)); + + if (!res) + { + /* First insertion in the hash. */ + res = xstrdup (quotearg_style (escape_quoting_style, s)); + hash_insert (struniqs_table, res); + } + return res; +} + + +/*--------------------. +| Print the struniq. | +`--------------------*/ + +static bool +struniq_print (const struniq_t s) +{ + fprintf (stderr, "%s\n", s); + return true; +} + + +/*-----------------------. +| A struniq hash table. | +`-----------------------*/ + +static bool +hash_compare_struniq_t (const struniq_t m1, const struniq_t m2) +{ + return strcmp (m1, m2) == 0; +} + +static unsigned int +hash_struniq_t (const struniq_t m, unsigned int tablesize) +{ + return hash_string (m, tablesize); +} + +/* A function to apply to each symbol. */ +typedef bool (*struniq_processor_t) (const struniq_t); + +/*----------------------------. +| Create the struniqs table. | +`----------------------------*/ + +void +struniqs_new (void) +{ + struniqs_table = hash_initialize (HT_INITIAL_CAPACITY, + NULL, + (Hash_hasher) hash_struniq_t, + (Hash_comparator) hash_compare_struniq_t, + (Hash_data_freer) free); +} + + +/*-------------------------------------. +| Perform a task on all the struniqs. | +`-------------------------------------*/ + +static void +struniqs_do (struniq_processor_t processor, void *processor_data) +{ + hash_do_for_each (struniqs_table, + (Hash_processor) processor, + processor_data); +} + + +/*-----------------. +| Print them all. | +`-----------------*/ + +void +struniqs_print (void) +{ + struniqs_do (struniq_print, NULL); +} + + +/*--------------------. +| Free the struniqs. | +`--------------------*/ + +void +struniqs_free (void) +{ + hash_free (struniqs_table); +} diff --git a/src/struniq.h b/src/struniq.h new file mode 100644 index 00000000..e83a0834 --- /dev/null +++ b/src/struniq.h @@ -0,0 +1,46 @@ +/* Keeping a unique copy of strings. + Copyright (C) 2002 Free Software Foundation, Inc. + + This file is part of Bison, the GNU Compiler Compiler. + + Bison is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2, or (at your option) + any later version. + + Bison is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with Bison; see the file COPYING. If not, write to + the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ + +#ifndef STRUNIQ_H_ +# define STRUNIQ_H_ + +/*------------------------------------------------------. +| struniq_t -- pointers to unique copies of C strings. | +`------------------------------------------------------*/ + +typedef char *struniq_t; + +/* Return the struniq for S. */ +const struniq_t struniq_new (const char *s); + +/*--------------------------------------. +| Initializing, destroying, debugging. | +`--------------------------------------*/ + +/* Create the string table. */ +void struniqs_new (void); + +/* Free all the memory allocated for symbols. */ +void struniqs_free (void); + +/* Report them all. */ +void struniqs_print (void); + +#endif /* !STRUNIQ_H_ */ diff --git a/src/symtab.c b/src/symtab.c index 7a2ac14b..c293de2a 100644 --- a/src/symtab.c +++ b/src/symtab.c @@ -200,13 +200,8 @@ symbol_user_token_number_set (symbol_t *symbol, static void symbol_free (symbol_t *this) { -#if 0 - /* This causes crashes because one string can appear more - than once. */ - XFREE (this->type_name); -#endif - XFREE (this->tag); - XFREE (this); + free (this->tag); + free (this); } diff --git a/src/symtab.h b/src/symtab.h index 61bd4017..ecf28cd0 100644 --- a/src/symtab.h +++ b/src/symtab.h @@ -22,6 +22,7 @@ #ifndef SYMTAB_H_ # define SYMTAB_H_ +# include "struniq.h" # include "location.h" # include "assoc.h" @@ -52,7 +53,7 @@ struct symbol_s location_t location; /* Its %type and associated printer and destructor. */ - char *type_name; + struniq_t type_name; char *destructor; location_t destructor_location; char *printer;