]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
fixing a few leaks - code_write doesn't delete the code object anymore, code_cleanup...
authorWolfgang Bumiller <wry.git@bumiller.com>
Tue, 7 May 2013 17:56:41 +0000 (19:56 +0200)
committerWolfgang Bumiller <wry.git@bumiller.com>
Tue, 7 May 2013 17:56:41 +0000 (19:56 +0200)
code.c
ftepp.c
gmqcc.h
ir.c
parser.c

diff --git a/code.c b/code.c
index 77bba3ec651dbadbf9d0085e665aaf0456a82e07..80154d0b03ae9be28ed57d71146d08f30d0f1532 100644 (file)
--- 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 595b520fec5439f34a1614f737f9f83f7ef3c150..9fc0025681499f99823184a7f54d58a2a5b82932 100644 (file)
--- 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 0031227457eded092b0b4d25d7e5793b5d45d464..033a2d027c4347fe2f8cf8b0a02aa5e8b5d4cd46 100644 (file)
--- 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 a124bd1fa60e1c608a276780812f321cfdc8a594..00d08756e1c11885c1b2831773ba41efe5629ecb 100644 (file)
--- 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]);
     }
index 5d36bfed3ba37dcfa0cfe88e4971338f21ce2b74..6ad55025c3896b9cf9d435985ad9b9a2cb45e92e 100644 (file)
--- 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);
 }