exec_node: Add new talloc-based new()
And fix all callers to use the tallbac-based new for exec_node construction. We make ready use of talloc_parent in order to get valid, (and appropriate) talloc owners for everything we construct without having to add new 'ctx' parameters up and down all the call trees. This closes the majority of the memory leaks in the glsl-orangebook-ch06-bump.frag test: total heap usage: 55,623 allocs, 42,672 frees (was 14,533 frees) Now 76.7% leak-free. Woo-hoo!
This commit is contained in:
@@ -94,6 +94,7 @@ do_function_inlining(exec_list *instructions)
|
||||
ir_rvalue *
|
||||
ir_call::generate_inline(ir_instruction *next_ir)
|
||||
{
|
||||
void *ctx = talloc_parent(this);
|
||||
ir_variable **parameters;
|
||||
int num_parameters;
|
||||
int i;
|
||||
@@ -110,7 +111,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
|
||||
|
||||
/* Generate storage for the return value. */
|
||||
if (this->callee->return_type) {
|
||||
retval = new ir_variable(this->callee->return_type, "__retval");
|
||||
retval = new(ctx) ir_variable(this->callee->return_type, "__retval");
|
||||
next_ir->insert_before(retval);
|
||||
}
|
||||
|
||||
@@ -133,8 +134,8 @@ ir_call::generate_inline(ir_instruction *next_ir)
|
||||
parameters[i]->mode == ir_var_inout) {
|
||||
ir_assignment *assign;
|
||||
|
||||
assign = new ir_assignment(new ir_dereference_variable(parameters[i]),
|
||||
param, NULL);
|
||||
assign = new(ctx) ir_assignment(new(ctx) ir_dereference_variable(parameters[i]),
|
||||
param, NULL);
|
||||
next_ir->insert_before(assign);
|
||||
}
|
||||
|
||||
@@ -162,9 +163,9 @@ ir_call::generate_inline(ir_instruction *next_ir)
|
||||
parameters[i]->mode == ir_var_inout) {
|
||||
ir_assignment *assign;
|
||||
|
||||
assign = new ir_assignment(param->as_rvalue(),
|
||||
new ir_dereference_variable(parameters[i]),
|
||||
NULL);
|
||||
assign = new(ctx) ir_assignment(param->as_rvalue(),
|
||||
new(ctx) ir_dereference_variable(parameters[i]),
|
||||
NULL);
|
||||
next_ir->insert_before(assign);
|
||||
}
|
||||
|
||||
@@ -176,7 +177,7 @@ ir_call::generate_inline(ir_instruction *next_ir)
|
||||
hash_table_dtor(ht);
|
||||
|
||||
if (retval)
|
||||
return new ir_dereference_variable(retval);
|
||||
return new(ctx) ir_dereference_variable(retval);
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user