glsl: Free all S-Expressions immediately after reading IR.
authorKenneth Graunke <kenneth@whitecape.org>
Thu, 22 Sep 2011 20:05:03 +0000 (13:05 -0700)
committerKenneth Graunke <kenneth@whitecape.org>
Sat, 24 Sep 2011 00:12:47 +0000 (17:12 -0700)
For some reason I thought subexpressions were chained off the top-level
one.  This isn't the case, so just create a temporary context and free
it.  All of this memory would be eventually freed, but now is freed
much sooner.

Signed-off-by: Kenneth Graunke <kenneth@whitecape.org>
src/glsl/ir_reader.cpp

index 2d0bccb78cd2dabad15a3810e64bba406a18e7fe..afb06b3beff530e90ad45f8b6d74e01462d34edf 100644 (file)
@@ -79,7 +79,8 @@ _mesa_glsl_read_ir(_mesa_glsl_parse_state *state, exec_list *instructions,
 void
 ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos)
 {
-   s_expression *expr = s_expression::read_expression(mem_ctx, src);
+   void *sx_mem_ctx = ralloc_context(NULL);
+   s_expression *expr = s_expression::read_expression(sx_mem_ctx, src);
    if (expr == NULL) {
       ir_read_error(NULL, "couldn't parse S-Expression.");
       return;
@@ -92,7 +93,7 @@ ir_reader::read(exec_list *instructions, const char *src, bool scan_for_protos)
    }
 
    read_instructions(instructions, expr, NULL);
-   ralloc_free(expr);
+   ralloc_free(sx_mem_ctx);
 
    if (debug)
       validate_ir_tree(instructions);