[PATCH 2/4] Use common code to free the loaded symbols list |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/hatari-devel Archives
]
- Subject: [PATCH 2/4] Use common code to free the loaded symbols list
- From: Thorsten Otto <admin@xxxxxxxxxxx>
- Date: Wed, 31 Mar 2021 18:46:37 +0200
---
src/debug/symbols-common.c | 26 ++++++++++++++++++++++----
src/debug/symbols.c | 25 +------------------------
2 files changed, 23 insertions(+), 28 deletions(-)
diff --git a/src/debug/symbols-common.c b/src/debug/symbols-common.c
index f36025c4..ed6ae35b 100644
--- a/src/debug/symbols-common.c
+++ b/src/debug/symbols-common.c
@@ -192,12 +192,30 @@ static symbol_list_t* symbol_list_alloc(int symbols)
*/
static void symbol_list_free(symbol_list_t *list)
{
- if (list) {
- if (list->names) {
- free(list->names);
+ int i;
+
+ if (!list) {
+ return;
+ }
+ assert(list->namecount);
+ if (list->strtab) {
+ free(list->strtab);
+ list->strtab = NULL;
+ } else {
+ for (i = 0; i < list->namecount; i++) {
+ free(list->names[i].name);
}
- free(list);
}
+ free(list->addresses);
+ free(list->names);
+
+ /* catch use of freed list */
+ list->addresses = NULL;
+ list->codecount = 0;
+ list->datacount = 0;
+ list->names = NULL;
+ list->namecount = 0;
+ free(list);
}
/**
diff --git a/src/debug/symbols.c b/src/debug/symbols.c
index 982f88bf..b48bb529 100644
--- a/src/debug/symbols.c
+++ b/src/debug/symbols.c
@@ -310,30 +310,7 @@ static symbol_list_t* Symbols_Load(const char *filename, Uint32 *offsets, Uint32
*/
static void Symbols_Free(symbol_list_t* list)
{
- int i;
-
- if (!list) {
- return;
- }
- assert(list->namecount);
- if (list->strtab) {
- free(list->strtab);
- list->strtab = NULL;
- } else {
- for (i = 0; i < list->namecount; i++) {
- free(list->names[i].name);
- }
- }
- free(list->addresses);
- free(list->names);
-
- /* catch use of freed list */
- list->addresses = NULL;
- list->codecount = 0;
- list->datacount = 0;
- list->names = NULL;
- list->namecount = 0;
- free(list);
+ symbol_list_free(list);
}
--
2.24.0
--nextPart3945085.DFmjOQq6lO
Content-Disposition: attachment; filename="0001-Move-common-symbol-loading-code-to-separate-file.patch"
Content-Transfer-Encoding: 7Bit
Content-Type: text/x-patch; charset="UTF-8"; name="0001-Move-common-symbol-loading-code-to-separate-file.patch"