From 450136d368ce7a08cf25992c79b51f51f8a9bb7c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 14 May 2008 12:37:07 -0600 Subject: mesa: added _mesa_free_instructions() cherry-picked from gallium-0.1 --- src/mesa/shader/prog_instruction.c | 17 +++++++++++++++++ src/mesa/shader/prog_instruction.h | 3 +++ 2 files changed, 20 insertions(+) diff --git a/src/mesa/shader/prog_instruction.c b/src/mesa/shader/prog_instruction.c index d6b5652a276..329fec3bac7 100644 --- a/src/mesa/shader/prog_instruction.c +++ b/src/mesa/shader/prog_instruction.c @@ -118,6 +118,23 @@ _mesa_copy_instructions(struct prog_instruction *dest, } +/** + * Free an array of instructions + */ +void +_mesa_free_instructions(struct prog_instruction *inst, GLuint count) +{ + GLuint i; + for (i = 0; i < count; i++) { + if (inst[i].Data) + _mesa_free(inst[i].Data); + if (inst[i].Comment) + _mesa_free((char *) inst[i].Comment); + } + _mesa_free(inst); +} + + /** * Basic info about each instruction */ diff --git a/src/mesa/shader/prog_instruction.h b/src/mesa/shader/prog_instruction.h index c800757aa0f..ce4daec1041 100644 --- a/src/mesa/shader/prog_instruction.h +++ b/src/mesa/shader/prog_instruction.h @@ -437,6 +437,9 @@ extern struct prog_instruction * _mesa_copy_instructions(struct prog_instruction *dest, const struct prog_instruction *src, GLuint n); +extern void +_mesa_free_instructions(struct prog_instruction *inst, GLuint count); + extern GLuint _mesa_num_inst_src_regs(gl_inst_opcode opcode); -- cgit v1.2.3