aboutsummaryrefslogtreecommitdiff
path: root/bin/sh/arith_lex.l
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2010-04-25 20:43:19 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2010-04-25 20:43:19 +0000
commit593e925a73be1cfa1eb0a9904b7da7493b279d6f (patch)
tree0d483cc468eee9850434c86361d24e23e247d468 /bin/sh/arith_lex.l
parent0d2e1c3e39359263dc3342b3105db2bec383e3cd (diff)
downloadsrc-593e925a73be1cfa1eb0a9904b7da7493b279d6f.tar.gz
src-593e925a73be1cfa1eb0a9904b7da7493b279d6f.zip
sh: Use stalloc for arith variable names.
This is simpler than the custom memory tracker I added earlier, and is also needed by the dash arith code I plan to import.
Notes
Notes: svn path=/head/; revision=207206
Diffstat (limited to 'bin/sh/arith_lex.l')
-rw-r--r--bin/sh/arith_lex.l26
1 files changed, 3 insertions, 23 deletions
diff --git a/bin/sh/arith_lex.l b/bin/sh/arith_lex.l
index f0d9cb34c412..aede40fd93d2 100644
--- a/bin/sh/arith_lex.l
+++ b/bin/sh/arith_lex.l
@@ -51,13 +51,6 @@ __FBSDID("$FreeBSD$");
int yylex(void);
-struct varname
-{
- struct varname *next;
- char name[1];
-};
-static struct varname *varnames;
-
#undef YY_INPUT
#define YY_INPUT(buf,result,max) \
result = (*buf = *arith_buf++) ? 1 : YY_NULL;
@@ -87,14 +80,11 @@ static struct varname *varnames;
* If variable doesn't exist, we should initialize
* it to zero.
*/
- struct varname *temp;
+ char *temp;
if (lookupvar(yytext) == NULL)
setvarsafe(yytext, "0", 0);
- temp = ckmalloc(sizeof(struct varname) +
- strlen(yytext));
- temp->next = varnames;
- varnames = temp;
- yylval.s_value = strcpy(temp->name, yytext);
+ temp = stalloc(strlen(yytext) + 1);
+ yylval.s_value = strcpy(temp, yytext);
return ARITH_VAR;
}
@@ -140,15 +130,5 @@ static struct varname *varnames;
void
arith_lex_reset(void)
{
- struct varname *name, *next;
-
YY_NEW_FILE;
-
- name = varnames;
- while (name != NULL) {
- next = name->next;
- ckfree(name);
- name = next;
- }
- varnames = NULL;
}