diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2019-02-05 22:03:38 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2019-02-05 22:03:38 (GMT) |
commit | 17f591f2230ac66394467d5e5eefe71cb259637d (patch) | |
tree | 1664e994b2904e5e9009027fc57749a11667365b /src/arch/processor.c | |
parent | ff187d24b7441e88e1f0361d59b0f6f55851791f (diff) |
Fixed a huge number of memory leaks.
Diffstat (limited to 'src/arch/processor.c')
-rw-r--r-- | src/arch/processor.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/src/arch/processor.c b/src/arch/processor.c index 05e3206..dccd12e 100644 --- a/src/arch/processor.c +++ b/src/arch/processor.c @@ -190,8 +190,18 @@ static void g_arch_processor_dispose(GArchProcessor *proc) size_t i; /* Boucle de parcours */ for (i = 0; i < proc->instr_count; i++) + { + /** + * Pour éviter un cycle de maintien des références, on détruit tous + * les liens depuis l'extérieur ! + */ + if (proc->instructions[i] != NULL) + g_arch_instruction_delete_all_links(proc->instructions[i]); + g_clear_object(&proc->instructions[i]); + } + g_mutex_clear(&proc->mutex); g_mutex_clear(&proc->error_mutex); @@ -230,6 +240,9 @@ static void g_arch_processor_finalize(GArchProcessor *proc) } + if (proc->coverages != NULL) + free(proc->coverages); + G_OBJECT_CLASS(g_arch_processor_parent_class)->finalize(G_OBJECT(proc)); } @@ -974,8 +987,7 @@ static void g_arch_processor_add_new_coverage(GArchProcessor *proc, GArchInstruc { proc->cov_allocated += COV_ALLOC_BLOCK; - proc->coverages = (instr_coverage *)realloc(proc->coverages, - proc->cov_allocated * sizeof(instr_coverage)); + proc->coverages = realloc(proc->coverages, proc->cov_allocated * sizeof(instr_coverage)); } |