From a673805f42882d1cb2a14efa14f5210835dd4aa2 Mon Sep 17 00:00:00 2001 From: owomomo Date: Sat, 19 Dec 2020 14:42:29 +0800 Subject: [PATCH] Add single comment without name with symbol naming dialog. --- src/drivers/win/debuggersp.cpp | 43 +++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/src/drivers/win/debuggersp.cpp b/src/drivers/win/debuggersp.cpp index 9423f90a..512d3364 100644 --- a/src/drivers/win/debuggersp.cpp +++ b/src/drivers/win/debuggersp.cpp @@ -1023,7 +1023,7 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* break; } - if (*newName) + if (*newName || *newComment) { if (!initialNode) { @@ -1032,8 +1032,15 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* node->offset = (char*)malloc(strlen(newOffset) + 1); strcpy(node->offset, newOffset); node->offsetNumeric = newAddress; - node->name = (char*)malloc(strlen(newName) + 1); - strcpy(node->name, newName); + if (strlen(newName)) + { + node->name = (char*)malloc(strlen(newName) + 1); + strcpy(node->name, newName); + } + else + { + node->name = 0; + } if (strlen(newComment)) { node->comment = (char*)malloc(strlen(newComment) + 1); @@ -1054,17 +1061,25 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* // found matching address - replace its name and comment if (node->name) free(node->name); - node->name = (char*)malloc(strlen(newName) + 1); - strcpy(node->name, newName); + if (strlen(node->name)) + { + node->name = (char*)malloc(strlen(newName) + 1); + strcpy(node->name, newName); + } else + { + node->name = 0; + } if (node->comment) { free(node->comment); - node->comment = 0; } if (strlen(newComment)) { node->comment = (char*)malloc(strlen(newComment) + 1); strcpy(node->comment, newComment); + } else + { + node->comment = 0; } break; } @@ -1079,14 +1094,20 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* newNode->offset = (char*)malloc(strlen(newOffset) + 1); strcpy(newNode->offset, newOffset); newNode->offsetNumeric = newAddress; - newNode->name = (char*)malloc(strlen(newName) + 1); - strcpy(newNode->name, newName); + + if (strlen(newName)) + { + newNode->name = (char*)malloc(strlen(newName) + 1); + strcpy(newNode->name, newName); + } + else { + newNode->name = 0; + } if (strlen(newComment)) { newNode->comment = (char*)malloc(strlen(newComment) + 1); strcpy(newNode->comment, newComment); - } else - { + } else { newNode->comment = 0; } newNode->next = 0; @@ -1096,7 +1117,7 @@ void AddNewSymbolicName(uint16 newAddress, char* newOffset, char* newName, char* } } else { - // name field is empty - remove the address from the list + // name and comment field are all empty - remove the address from the list Name* previousNode = 0; while (node) {