summaryrefslogtreecommitdiffstats
path: root/src/glsl
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2013-07-12 09:27:22 +0100
committerJosé Fonseca <[email protected]>2013-07-12 09:28:22 +0100
commit649ef4da30e23f077087326a6a9116759f1d9dd3 (patch)
tree456c29be68d2c737797813896d5c438e29b89cd0 /src/glsl
parent1b0d6aef03161eff4c9933548e964fec1258ea44 (diff)
glsl: Avoid variable length arrays.
They are a non-standard GCC extension that's not widely supported by other C/C++ compilers. Use a dynamic array instead. Trivial. Should fix the MSVC build.
Diffstat (limited to 'src/glsl')
-rw-r--r--src/glsl/glsl_symbol_table.cpp21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/glsl/glsl_symbol_table.cpp b/src/glsl/glsl_symbol_table.cpp
index 0bea5364ef5..4c96620bfdb 100644
--- a/src/glsl/glsl_symbol_table.cpp
+++ b/src/glsl/glsl_symbol_table.cpp
@@ -175,13 +175,21 @@ bool glsl_symbol_table::add_type(const char *name, const glsl_type *t)
return _mesa_symbol_table_add_symbol(table, -1, name, entry) == 0;
}
-bool glsl_symbol_table::add_type_ast(const char *name, const class ast_type_specifier *a)
+static char *make_ast_name(const char *name)
{
- symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(a);
- char ast_name[strlen("#ast.") + strlen(name) + 1];
+ char *ast_name = new char[strlen("#ast.") + strlen(name) + 1];
strcpy(ast_name, "#ast.");
strcat(ast_name + strlen("#ast."), name);
- return _mesa_symbol_table_add_symbol(table, -1, ast_name, entry) == 0;
+ return ast_name;
+}
+
+bool glsl_symbol_table::add_type_ast(const char *name, const class ast_type_specifier *a)
+{
+ symbol_table_entry *entry = new(mem_ctx) symbol_table_entry(a);
+ char *ast_name = make_ast_name(name);
+ bool ret = _mesa_symbol_table_add_symbol(table, -1, ast_name, entry) == 0;
+ delete [] ast_name;
+ return ret;
}
bool glsl_symbol_table::add_interface(const char *name, const glsl_type *i,
@@ -237,10 +245,9 @@ const glsl_type *glsl_symbol_table::get_type(const char *name)
const class ast_type_specifier *glsl_symbol_table::get_type_ast(const char *name)
{
- char ast_name[strlen("#ast.") + strlen(name) + 1];
- strcpy(ast_name, "#ast.");
- strcat(ast_name + strlen("#ast."), name);
+ char *ast_name = make_ast_name(name);
symbol_table_entry *entry = get_entry(ast_name);
+ delete [] ast_name;
return entry != NULL ? entry->a : NULL;
}