}
_mesa_symbol_table_add_symbol(state->st, 0, s->name, s);
+ s->next = state->sym;
+ state->sym = s;
}
return s;
struct asm_instruction *inst;
unsigned i;
GLubyte *strz;
+ GLboolean result = GL_FALSE;
+ void *temp;
+ struct asm_symbol *sym;
state->ctx = ctx;
state->prog->Target = target;
if (ctx->Program.ErrorPos != -1) {
- return GL_FALSE;
+ goto error;
}
if (! _mesa_layout_parameters(state)) {
loc.position = len;
yyerror(& loc, state, "invalid PARAM usage");
- return GL_FALSE;
+ goto error;
}
struct asm_instruction *const temp = inst->next;
state->prog->Instructions[i] = inst->Base;
- _mesa_free(inst);
-
inst = temp;
}
state->prog->NumNativeAttributes = state->prog->NumAttributes;
state->prog->NumNativeAddressRegs = state->prog->NumAddressRegs;
- return GL_TRUE;
+ result = GL_TRUE;
+
+error:
+ for (inst = state->inst_head; inst != NULL; inst = temp) {
+ temp = inst->next;
+ _mesa_free(inst);
+ }
+
+ state->inst_head = NULL;
+ state->inst_tail = NULL;
+
+ for (sym = state->sym; sym != NULL; sym = temp) {
+ temp = sym->next;
+
+ _mesa_free(sym->name);
+ _mesa_free(sym);
+ }
+ state->sym = NULL;
+
+ _mesa_symbol_table_dtor(state->st);
+ state->st = NULL;
+
+ return result;
}
}
_mesa_symbol_table_add_symbol(state->st, 0, s->name, s);
+ s->next = state->sym;
+ state->sym = s;
}
return s;
struct asm_instruction *inst;
unsigned i;
GLubyte *strz;
+ GLboolean result = GL_FALSE;
+ void *temp;
+ struct asm_symbol *sym;
state->ctx = ctx;
state->prog->Target = target;
if (ctx->Program.ErrorPos != -1) {
- return GL_FALSE;
+ goto error;
}
if (! _mesa_layout_parameters(state)) {
loc.position = len;
yyerror(& loc, state, "invalid PARAM usage");
- return GL_FALSE;
+ goto error;
}
struct asm_instruction *const temp = inst->next;
state->prog->Instructions[i] = inst->Base;
- _mesa_free(inst);
-
inst = temp;
}
state->prog->NumNativeAttributes = state->prog->NumAttributes;
state->prog->NumNativeAddressRegs = state->prog->NumAddressRegs;
- return GL_TRUE;
+ result = GL_TRUE;
+
+error:
+ for (inst = state->inst_head; inst != NULL; inst = temp) {
+ temp = inst->next;
+ _mesa_free(inst);
+ }
+
+ state->inst_head = NULL;
+ state->inst_tail = NULL;
+
+ for (sym = state->sym; sym != NULL; sym = temp) {
+ temp = sym->next;
+
+ _mesa_free((void *) sym->name);
+ _mesa_free(sym);
+ }
+ state->sym = NULL;
+
+ _mesa_symbol_table_dtor(state->st);
+ state->st = NULL;
+
+ return result;
}
};
struct asm_symbol {
+ struct asm_symbol *next; /**< List linkage for freeing. */
const char *name;
enum asm_type type;
unsigned attrib_binding;
struct _mesa_symbol_table *st;
+ /**
+ * Linked list of symbols
+ *
+ * This list is \b only used when cleaning up compiler state and freeing
+ * memory.
+ */
+ struct asm_symbol *sym;
+
/**
* State for the lexer.
*/