call slang_variable_construct() inside slang_variable_scope_grow()
authorBrian Paul <brian.paul@tungstengraphics.com>
Fri, 24 Nov 2006 19:21:42 +0000 (19:21 +0000)
committerBrian Paul <brian.paul@tungstengraphics.com>
Fri, 24 Nov 2006 19:21:42 +0000 (19:21 +0000)
src/mesa/shader/slang/slang_compile.c
src/mesa/shader/slang/slang_compile_variable.c

index 93c7fb0cdbf8d5b228442fde05bdcadc15936627..c49ab4a68dc1c7bc6f563a1fd96d22958be0e758 100644 (file)
@@ -439,8 +439,6 @@ parse_struct_field(slang_parse_ctx * C, slang_output_ctx * O,
          slang_info_log_memory(C->L);
          return 0;
       }
-      if (!slang_variable_construct(var))
-         return 0;
       if (!parse_struct_field_var(C, &o, var, sp))
          return 0;
    }
@@ -1478,8 +1476,6 @@ parse_function_prototype(slang_parse_ctx * C, slang_output_ctx * O,
          slang_info_log_memory(C->L);
          return 0;
       }
-      if (!slang_variable_construct(p))
-         return 0;
       if (!parse_parameter_declaration(C, O, p))
          return 0;
    }
@@ -1654,8 +1650,6 @@ parse_init_declarator(slang_parse_ctx * C, slang_output_ctx * O,
       slang_info_log_memory(C->L);
       return 0;
    }
-   if (!slang_variable_construct(var))
-      return 0;
 
    /* copy the declarator qualifier type, parse the identifier */
    var->global = C->global_scope;
index a37deddff1071a0867771c15de1cc66778c16ad5..a8a2d6aa6a0629c245e92dbf43e3635ccf6842e3 100644 (file)
@@ -184,7 +184,7 @@ slang_variable_scope_copy(slang_variable_scope * x,
 
 /**
  * Grow the variable list by one.
- * \return  pointer to space for the new variable.
+ * \return  pointer to space for the new variable (will be initialized)
  */
 slang_variable *
 slang_variable_scope_grow(slang_variable_scope *scope)
@@ -196,7 +196,12 @@ slang_variable_scope_grow(slang_variable_scope *scope)
                              (n + 1) * sizeof(slang_variable));
    if (!scope->variables)
       return NULL;
+
    scope->num_variables++;
+
+   if (!slang_variable_construct(scope->variables + n))
+      return NULL;
+
    return scope->variables + n;
 }