From: Wolfgang Bumiller Date: Tue, 7 May 2013 17:56:41 +0000 (+0200) Subject: fixing a few leaks - code_write doesn't delete the code object anymore, code_cleanup... X-Git-Tag: v0.3.0~151^2~52 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=c5225b2fa1e314447392febdd1dee2a2a1744016;p=xonotic%2Fgmqcc.git fixing a few leaks - code_write doesn't delete the code object anymore, code_cleanup has to be called --- diff --git a/code.c b/code.c index 77bba3e..80154d0 100644 --- a/code.c +++ b/code.c @@ -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; } diff --git a/ftepp.c b/ftepp.c index 595b520..9fc0025 100644 --- a/ftepp.c +++ b/ftepp.c @@ -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 { diff --git a/gmqcc.h b/gmqcc.h index 0031227..033a2d0 100644 --- a/gmqcc.h +++ b/gmqcc.h @@ -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); diff --git a/ir.c b/ir.c index a124bd1..00d0875 100644 --- a/ir.c +++ b/ir.c @@ -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]); } diff --git a/parser.c b/parser.c index 5d36bfe..6ad5502 100644 --- a/parser.c +++ b/parser.c @@ -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); }