diff options
author | jilles <jilles@FreeBSD.org> | 2010-04-25 20:43:19 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2010-04-25 20:43:19 +0000 |
commit | 88403fad183ba6067547daa0d779c87bf100403f (patch) | |
tree | 0d483cc468eee9850434c86361d24e23e247d468 /bin/sh/arith_lex.l | |
parent | 019a1d16bacaa7783b857c309ce61d655e899904 (diff) | |
download | FreeBSD-src-88403fad183ba6067547daa0d779c87bf100403f.zip FreeBSD-src-88403fad183ba6067547daa0d779c87bf100403f.tar.gz |
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.
Diffstat (limited to 'bin/sh/arith_lex.l')
-rw-r--r-- | bin/sh/arith_lex.l | 26 |
1 files changed, 3 insertions, 23 deletions
diff --git a/bin/sh/arith_lex.l b/bin/sh/arith_lex.l index f0d9cb3..aede40f 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; } |