summaryrefslogtreecommitdiffstats
path: root/src/mesa/shader/program_lexer.l
diff options
context:
space:
mode:
authorIan Romanick <[email protected]>2009-11-04 12:03:44 -0800
committerIan Romanick <[email protected]>2009-11-06 10:46:22 -0800
commit1c7337d46eab0cfd36ebc0ad22c5a66ec9b91d39 (patch)
tree87f265f2f530c1a68bc48a5b00100f94d167788d /src/mesa/shader/program_lexer.l
parent63191bd244f18fd78bebb9586d2b85ab9d5b38e2 (diff)
Revert "ARB prog parser: Fix epic memory leak in lexer / parser interface"
This reverts commit 93dae6761bc90bbd43b450d2673620ec189b2c7a. This change was completely broken when the parser uses multiple strings in a single production. It would be nice if bug fixes could initially land somewhere other than the stable branch.
Diffstat (limited to 'src/mesa/shader/program_lexer.l')
-rw-r--r--src/mesa/shader/program_lexer.l45
1 files changed, 3 insertions, 42 deletions
diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l
index 6c4fad30372..c2803ff7074 100644
--- a/src/mesa/shader/program_lexer.l
+++ b/src/mesa/shader/program_lexer.l
@@ -40,7 +40,7 @@
if (condition) { \
return token; \
} else { \
- yylval->string = return_string(yyextra, yytext); \
+ yylval->string = strdup(yytext); \
return IDENTIFIER; \
} \
} while (0)
@@ -63,7 +63,7 @@
yylval->temp_inst.SaturateMode = SATURATE_ ## sat; \
return token; \
} else { \
- yylval->string = return_string(yyextra, yytext); \
+ yylval->string = strdup(yytext); \
return IDENTIFIER; \
} \
} while (0)
@@ -71,45 +71,6 @@
#define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \
SWIZZLE_NIL, SWIZZLE_NIL)
-/**
- * Send a string to the parser using asm_parser_state::string_dumpster
- *
- * Sends a string to the parser using asm_parser_state::string_dumpster as a
- * temporary storage buffer. Data previously stored in
- * asm_parser_state::string_dumpster will be lost. If
- * asm_parser_state::string_dumpster is not large enough to hold the new
- * string, the buffer size will be increased. The buffer size is \b never
- * decreased.
- *
- * \param state Assembler parser state tracking
- * \param str String to be passed to the parser
- *
- * \return
- * A pointer to asm_parser_state::string_dumpster on success or \c NULL on
- * failure. Currently the only failure case is \c ENOMEM.
- */
-static char *
-return_string(struct asm_parser_state *state, const char *str)
-{
- const size_t len = strlen(str);
-
- if (len >= state->dumpster_size) {
- char *const dumpster = _mesa_realloc(state->string_dumpster,
- state->dumpster_size,
- len + 1);
- if (dumpster == NULL) {
- return NULL;
- }
-
- state->string_dumpster = dumpster;
- state->dumpster_size = len + 1;
- }
-
- memcpy(state->string_dumpster, str, len + 1);
- return state->string_dumpster;
-}
-
-
static unsigned
mask_from_char(char c)
{
@@ -347,7 +308,7 @@ ARRAYSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require
ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); }
[_a-zA-Z$][_a-zA-Z0-9$]* {
- yylval->string = return_string(yyextra, yytext);
+ yylval->string = strdup(yytext);
return IDENTIFIER;
}