summaryrefslogtreecommitdiff
path: root/ir.cpp
diff options
context:
space:
mode:
authorEric Anholt <eric@anholt.net>2010-06-24 15:13:03 -0700
committerEric Anholt <eric@anholt.net>2010-06-24 15:13:03 -0700
commite33c10328caec29616a5433b1d1df9088f3a84df (patch)
tree723cc38803bb10032d28be9a9a161232d05d0fd1 /ir.cpp
parent9290e0dd28e646c3dc810e0a6405582f8bf643b6 (diff)
parent26bbfb7917a71d46d9227bbf960606cb673636d3 (diff)
Merge remote branch 'cworth/master'
Conflicts: ast_to_hir.cpp ir.cpp This brings in the talloc-based memory management work, so that the compiler (almost) no longer leaks memory.
Diffstat (limited to 'ir.cpp')
-rw-r--r--ir.cpp19
1 files changed, 12 insertions, 7 deletions
diff --git a/ir.cpp b/ir.cpp
index 9252ccfd3a..2756752ba4 100644
--- a/ir.cpp
+++ b/ir.cpp
@@ -466,8 +466,10 @@ ir_dereference_array::ir_dereference_array(ir_rvalue *value,
ir_dereference_array::ir_dereference_array(ir_variable *var,
ir_rvalue *array_index)
{
+ void *ctx = talloc_parent(var);
+
this->array_index = array_index;
- this->set_array(new ir_dereference_variable(var));
+ this->set_array(new(ctx) ir_dereference_variable(var));
}
@@ -504,7 +506,9 @@ ir_dereference_record::ir_dereference_record(ir_rvalue *value,
ir_dereference_record::ir_dereference_record(ir_variable *var,
const char *field)
{
- this->record = new ir_dereference_variable(var);
+ void *ctx = talloc_parent(var);
+
+ this->record = new(ctx) ir_dereference_variable(var);
this->field = field;
this->type = (this->record != NULL)
? this->record->type->field_type(field) : glsl_type::error_type;
@@ -615,6 +619,8 @@ ir_swizzle::ir_swizzle(ir_rvalue *val, ir_swizzle_mask mask)
ir_swizzle *
ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length)
{
+ void *ctx = talloc_parent(val);
+
/* For each possible swizzle character, this table encodes the value in
* \c idx_map that represents the 0th element of the vector. For invalid
* swizzle characters (e.g., 'k'), a special value is used that will allow
@@ -679,8 +685,8 @@ ir_swizzle::create(ir_rvalue *val, const char *str, unsigned vector_length)
if (str[i] != '\0')
return NULL;
- return new ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2],
- swiz_idx[3], i);
+ return new(ctx) ir_swizzle(val, swiz_idx[0], swiz_idx[1], swiz_idx[2],
+ swiz_idx[3], i);
}
#undef X
@@ -780,7 +786,6 @@ ir_function_signature::replace_parameters(exec_list *new_params)
assert(((ir_instruction *) iter.get())->as_variable() != NULL);
iter.remove();
- delete (ir_instruction*) iter.get();
}
new_params->move_nodes_to(&parameters);
@@ -795,9 +800,9 @@ ir_function::ir_function(const char *name)
ir_call *
-ir_call::get_error_instruction()
+ir_call::get_error_instruction(void *ctx)
{
- ir_call *call = new ir_call;
+ ir_call *call = new(ctx) ir_call;
call->type = glsl_type::error_type;
return call;