mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-03-22 10:41:43 +00:00
fixing a few leaks - code_write doesn't delete the code object anymore, code_cleanup has to be called
This commit is contained in:
parent
8c8ae71d65
commit
c5225b2fa1
5 changed files with 10 additions and 8 deletions
7
code.c
7
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;
|
||||
}
|
||||
|
|
6
ftepp.c
6
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 {
|
||||
|
|
1
gmqcc.h
1
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);
|
||||
|
|
1
ir.c
1
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]);
|
||||
}
|
||||
|
|
3
parser.c
3
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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue