diff options
author | Carl Worth <cworth@cworth.org> | 2010-06-23 18:11:51 -0700 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2010-06-23 18:59:35 -0700 |
commit | 1660a2954797e056caba319c5d6c70b0d4be22fe (patch) | |
tree | 172af2dd8effb58c89828b917cae850058312edd /ir_constant_expression.cpp | |
parent | 8f52c9b5fcbc73ed12b23253caa44c28fd4452e2 (diff) |
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!
Diffstat (limited to 'ir_constant_expression.cpp')
-rw-r--r-- | ir_constant_expression.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/ir_constant_expression.cpp b/ir_constant_expression.cpp index effb88844e..4010e46267 100644 --- a/ir_constant_expression.cpp +++ b/ir_constant_expression.cpp @@ -127,6 +127,7 @@ ir_constant_visitor::visit(ir_function *ir) void ir_constant_visitor::visit(ir_expression *ir) { + void *ctx = talloc_parent(ir); value = NULL; ir_constant *op[2]; unsigned int operand, c; @@ -497,7 +498,7 @@ ir_constant_visitor::visit(ir_expression *ir) return; } - this->value = new ir_constant(ir->type, &data); + this->value = new(ctx) ir_constant(ir->type, &data); } @@ -513,6 +514,7 @@ ir_constant_visitor::visit(ir_texture *ir) void ir_constant_visitor::visit(ir_swizzle *ir) { + void *ctx = talloc_parent(ir); ir_constant *v = ir->val->constant_expression_value(); this->value = NULL; @@ -534,7 +536,7 @@ ir_constant_visitor::visit(ir_swizzle *ir) } } - this->value = new ir_constant(ir->type, &data); + this->value = new(ctx) ir_constant(ir->type, &data); } } @@ -553,6 +555,7 @@ ir_constant_visitor::visit(ir_dereference_variable *ir) void ir_constant_visitor::visit(ir_dereference_array *ir) { + void *ctx = talloc_parent(ir); ir_constant *array = ir->array->constant_expression_value(); ir_constant *idx = ir->array_index->constant_expression_value(); @@ -592,11 +595,11 @@ ir_constant_visitor::visit(ir_dereference_array *ir) break; } - this->value = new ir_constant(column_type, &data); + this->value = new(ctx) ir_constant(column_type, &data); } else if (array->type->is_vector()) { const unsigned component = idx->value.u[0]; - this->value = new ir_constant(array, component); + this->value = new(ctx) ir_constant(array, component); } else { /* FINISHME: Handle access of constant arrays. */ } |