Merge pull request #1016 from tom-van/free-dm-target_list

Free dm and target_list structures
This commit is contained in:
Evgeniy Naydanov 2024-02-16 11:05:22 +03:00 committed by GitHub
commit a5464a54d3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 0 deletions

View File

@ -280,6 +280,29 @@ static dm013_info_t *get_dm(struct target *target)
return dm; return dm;
} }
static void riscv013_dm_free(struct target *target)
{
RISCV013_INFO(info);
dm013_info_t *dm = info->dm;
if (!dm)
return;
target_list_t *target_entry;
list_for_each_entry(target_entry, &dm->target_list, list) {
if (target_entry->target == target) {
list_del(&target_entry->list);
free(target_entry);
break;
}
}
if (list_empty(&dm->target_list)) {
list_del(&dm->list);
free(dm);
}
info->dm = NULL;
}
static riscv_debug_reg_ctx_t get_riscv_debug_reg_ctx(const struct target *target) static riscv_debug_reg_ctx_t get_riscv_debug_reg_ctx(const struct target *target)
{ {
if (!target_was_examined(target)) { if (!target_was_examined(target)) {
@ -1864,6 +1887,8 @@ static void deinit_target(struct target *target)
if (!info) if (!info)
return; return;
riscv013_dm_free(target);
free(info->version_specific); free(info->version_specific);
/* TODO: free register arch_info */ /* TODO: free register arch_info */
info->version_specific = NULL; info->version_specific = NULL;