diff options
author | Carl Worth <cworth@cworth.org> | 2010-06-18 17:43:40 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-06-23 19:00:42 -0700 |
commit | dc5811fd0c7600b165ddd4e04a0ccae69bb19ec8 (patch) | |
tree | 3c5c943c86c9e6175400e79617d48325438e6ba4 | |
parent | a9696e79fb3afc6a4724bd16ee1ccdfebebfd0fd (diff) |
Close memory leak in lexer.
Simply call talloc_strdup rather than strdup, (using the talloc_parent
of our 'state' object, (known here as yyextra).
This fix now makes glsl-orangebook-ch06-bump.frag 99.97% leak free:
total heap usage: 55,623 allocs, 55,609 frees
Only 14 missing frees now.
-rw-r--r-- | glsl_lexer.lpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/glsl_lexer.lpp b/glsl_lexer.lpp index c15c99c4b0..fa439f1278 100644 --- a/glsl_lexer.lpp +++ b/glsl_lexer.lpp @@ -312,7 +312,9 @@ highp return HIGHP; precision return PRECISION; [_a-zA-Z][_a-zA-Z0-9]* { - yylval->identifier = strdup(yytext); + struct _mesa_glsl_parse_state *state = yyextra; + void *ctx = talloc_parent(state); + yylval->identifier = talloc_strdup(ctx, yytext); return IDENTIFIER; } |