Skip to content

Commit

Permalink
Merge pull request #216 from flaviojs/fix-memory-leak-mips64-sym_tree
Browse files Browse the repository at this point in the history
Fix memory leak of mips64 sym_tree.
  • Loading branch information
grossmj authored Apr 2, 2024
2 parents 4a2e6a3 + 2a14929 commit 657f314
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
10 changes: 10 additions & 0 deletions stable/mips64.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,22 @@ int mips64_init(cpu_mips_t *cpu)
return(0);
}

/* Delete the symbol tree node */
static void mips64_delete_sym_tree_node(void *key, void *value, void *opt) {
free(key);
}

/* Delete a MIPS64 processor */
void mips64_delete(cpu_mips_t *cpu)
{
if (cpu) {
mips64_mem_shutdown(cpu);
mips64_jit_shutdown(cpu);
if (cpu->sym_tree) {
rbtree_foreach(cpu->sym_tree, mips64_delete_sym_tree_node, NULL);
rbtree_delete(cpu->sym_tree);
cpu->sym_tree = NULL;
}
}
}

Expand Down
10 changes: 10 additions & 0 deletions unstable/mips64.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,22 @@ int mips64_init(cpu_mips_t *cpu)
return(0);
}

/* Delete the symbol tree node */
static void mips64_delete_sym_tree_node(void *key, void *value, void *opt) {
free(key);
}

/* Delete a MIPS64 processor */
void mips64_delete(cpu_mips_t *cpu)
{
if (cpu) {
mips64_mem_shutdown(cpu);
mips64_jit_shutdown(cpu);
if (cpu->sym_tree) {
rbtree_foreach(cpu->sym_tree, mips64_delete_sym_tree_node, NULL);
rbtree_delete(cpu->sym_tree);
cpu->sym_tree = NULL;
}
}
}

Expand Down

0 comments on commit 657f314

Please sign in to comment.