From f2f793370871e5e833c80dd59921bc4c2f3a87bb Mon Sep 17 00:00:00 2001 From: Cary R Date: Thu, 8 Jan 2009 17:03:33 -0800 Subject: [PATCH] Make lexical token STRING new based. The STRING lexical token was malloc based, but then was passed to routines that are expecting a new based result. This patch standardizes on a new/delete based approach. --- lexor.lex | 4 ++-- parse.y | 8 ++++---- pform.cc | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/lexor.lex b/lexor.lex index 0b4bebd2c..c282a9bb9 100644 --- a/lexor.lex +++ b/lexor.lex @@ -168,12 +168,12 @@ S [afpnumkKMGT] \\\\ { yymore(); /* Catch \\, which is a \ escaping itself */ } \\\" { yymore(); /* Catch \", which is an escaped quote */ } \n { BEGIN(0); - yylval.text = strdup(yytext); + yylval.text = strdupnew(yytext); VLerror(yylloc, "Missing close quote of string."); yylloc.first_line += 1; return STRING; } \" { BEGIN(0); - yylval.text = strdup(yytext); + yylval.text = strdupnew(yytext); yylval.text[strlen(yytext)-1] = 0; return STRING; } . { yymore(); } diff --git a/parse.y b/parse.y index b78e8318c..777f1cc21 100644 --- a/parse.y +++ b/parse.y @@ -685,8 +685,8 @@ description | KK_attribute '(' IDENTIFIER ',' STRING ',' STRING ')' { perm_string tmp3 = lex_strings.make($3); pform_set_type_attrib(tmp3, $5, $7); - delete[]$3; - delete $5; + delete[] $3; + delete[] $5; } ; @@ -2301,8 +2301,8 @@ module_item { perm_string tmp3 = lex_strings.make($3); perm_string tmp5 = lex_strings.make($5); pform_set_attrib(tmp3, tmp5, $7); - delete[]$3; - delete $5; + delete[] $3; + delete[] $5; } | KK_attribute '(' error ')' ';' { yyerror(@1, "error: Malformed $attribute parameter list."); } diff --git a/pform.cc b/pform.cc index 521b699c6..7f1fb1cd3 100644 --- a/pform.cc +++ b/pform.cc @@ -1696,7 +1696,7 @@ void pform_set_attrib(perm_string name, perm_string key, char*value) curg->attributes[key] = new PEString(value); } else { - free(value); + delete[] value; VLerror("Unable to match name for setting attribute."); } @@ -1712,7 +1712,7 @@ void pform_set_type_attrib(perm_string name, const string&key, map::const_iterator udp = pform_primitives.find(name); if (udp == pform_primitives.end()) { VLerror("type name is not (yet) defined."); - free(value); + delete[] value; return; }