vc4: Fix memory leaks of struct qinst.

This commit is contained in:
Eric Anholt 2014-09-15 12:19:28 -07:00
parent f78ee1b280
commit 2147dd9681
4 changed files with 17 additions and 3 deletions

View File

@ -147,7 +147,7 @@ qir_opt_cse(struct vc4_compile *c)
qir_dump_inst(inst);
fprintf(stderr, "\n");
}
remove_from_list(&inst->link);
qir_remove_instruction(inst);
progress = true;
continue;
} else {

View File

@ -54,8 +54,7 @@ qir_opt_dead_code(struct vc4_compile *c)
qir_dump_inst(inst);
fprintf(stderr, "\n");
}
remove_from_list(&inst->link);
free(inst);
qir_remove_instruction(inst);
progress = true;
continue;
}

View File

@ -282,9 +282,23 @@ qir_compile_init(void)
return c;
}
void
qir_remove_instruction(struct qinst *qinst)
{
remove_from_list(&qinst->link);
free(qinst->src);
free(qinst);
}
void
qir_compile_destroy(struct vc4_compile *c)
{
while (!is_empty_list(&c->instructions)) {
struct qinst *qinst =
(struct qinst *)first_elem(&c->instructions);
qir_remove_instruction(qinst);
}
ralloc_free(c);
}

View File

@ -245,6 +245,7 @@ struct qinst *qir_inst4(enum qop op, struct qreg dst,
struct qreg b,
struct qreg c,
struct qreg d);
void qir_remove_instruction(struct qinst *qinst);
void qir_emit(struct vc4_compile *c, struct qinst *inst);
struct qreg qir_get_temp(struct vc4_compile *c);
int qir_get_op_nsrc(enum qop qop);