From 399e94f904b913a4093295426820ab89fc3cd24f Mon Sep 17 00:00:00 2001 From: Michael McConville Date: Wed, 2 Dec 2015 11:32:42 -0500 Subject: Made string copying more standard. copy_string() was a clone of the stdlib's strdup(). For safety, simplicity, and speed, we should use that instead. We introduce xstrdup() which wraps strdup() in a failure upon memory allocation errors. --- src/parse.y | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/parse.y') diff --git a/src/parse.y b/src/parse.y index 6e7246c..9bec1ee 100644 --- a/src/parse.y +++ b/src/parse.y @@ -193,19 +193,19 @@ optionlist : optionlist option option : OPT_OUTFILE '=' NAME { - outfilename = copy_string( nmstr ); + outfilename = xstrdup(nmstr); did_outfilename = 1; } | OPT_EXTRA_TYPE '=' NAME - { extra_type = copy_string( nmstr ); } + { extra_type = xstrdup(nmstr); } | OPT_PREFIX '=' NAME - { prefix = copy_string( nmstr ); } + { prefix = xstrdup(nmstr); } | OPT_YYCLASS '=' NAME - { yyclass = copy_string( nmstr ); } + { yyclass = xstrdup(nmstr); } | OPT_HEADER '=' NAME - { headerfilename = copy_string( nmstr ); } + { headerfilename = xstrdup(nmstr); } | OPT_TABLES '=' NAME - { tablesext = true; tablesfilename = copy_string( nmstr ); } + { tablesext = true; tablesfilename = xstrdup(nmstr); } ; sect2 : sect2 scon initforrule flexrule '\n' -- cgit v1.2.3