fixing a few leaks - code_write doesn't delete the code object anymore, code_cleanup has to be called

This commit is contained in:
Wolfgang Bumiller 2013-05-07 19:56:41 +02:00
parent 8c8ae71d65
commit c5225b2fa1
5 changed files with 10 additions and 8 deletions

7
code.c
View file

@ -354,6 +354,11 @@ bool code_write(code_t *code, const char *filename, const char *lnofile) {
}
}
fs_file_close(fp);
return true;
}
void code_cleanup(code_t *code) {
vec_free(code->statements);
vec_free(code->linenums);
vec_free(code->defs);
@ -364,7 +369,5 @@ bool code_write(code_t *code, const char *filename, const char *lnofile) {
util_htdel(code->string_cache);
fs_file_close(fp);
mem_d(code);
return true;
}

View file

@ -374,7 +374,7 @@ static GMQCC_INLINE ppmacro* ftepp_macro_find(ftepp_t *ftepp, const char *name)
static GMQCC_INLINE void ftepp_macro_delete(ftepp_t *ftepp, const char *name)
{
util_htrm(ftepp->macros, name, NULL);
util_htrm(ftepp->macros, name, (void (*)(void*))&ppmacro_delete);
}
static GMQCC_INLINE int ftepp_next(ftepp_t *ftepp)
@ -564,10 +564,6 @@ static bool ftepp_define(ftepp_t *ftepp)
return false;
}
#if 0
if (ftepp->output_on)
vec_push(ftepp->macros, macro);
#endif
if (ftepp->output_on)
util_htset(ftepp->macros, macro->name, (void*)macro);
else {

View file

@ -735,6 +735,7 @@ typedef struct {
*/
bool code_write (code_t *, const char *filename, const char *lno);
code_t *code_init (void);
void code_cleanup (code_t *);
uint32_t code_genstring (code_t *, const char *string);
qcint code_alloc_field (code_t *, size_t qcsize);
void code_push_statement(code_t *, prog_section_statement *stmt, int linenum);

1
ir.c
View file

@ -340,6 +340,7 @@ void ir_builder_delete(ir_builder* self)
ir_value_delete(self->extparams[i]);
}
vec_free(self->extparams);
vec_free(self->extparam_protos);
for (i = 0; i != vec_size(self->globals); ++i) {
ir_value_delete(self->globals[i]);
}

View file

@ -6016,7 +6016,6 @@ parser_t *parser_create()
mem_d(parser);
return NULL;
}
for (i = 0; i < operator_count; ++i) {
if (operators[i].id == opid1('=')) {
@ -6195,6 +6194,8 @@ void parser_cleanup(parser_t *parser)
intrin_intrinsics_destroy(parser);
code_cleanup(parser->code);
mem_d(parser);
}