1
0
mirror of https://github.com/simh/simh.git synced 2026-03-05 18:59:08 +00:00

SCP: Cleanup allocated memory assignments for C++ compatibility

This commit is contained in:
Mark Pizzolato
2025-10-24 08:19:42 -10:00
parent 68c9c5536f
commit d6a53f1c06
3 changed files with 7 additions and 7 deletions

8
scp.c
View File

@@ -2966,7 +2966,7 @@ t_stat reason;
MEMFILE mbuf;
memset (&mbuf, 0, sizeof (mbuf));
mbuf.buf = malloc (512); /* Pre allocate a memory buffer to avoid */
mbuf.buf = (char *)malloc (512); /* Pre allocate a memory buffer to avoid */
mbuf.size = 512; /* potential double vsnprintf to expand the buffer */
sim_mfile = &mbuf;
if (vm_flag || ((reason = fprint_sym (sim_tmpfile, addr, val, uptr, sw)) > 0)) {
@@ -5428,7 +5428,7 @@ if (sim_switches & SWMASK ('R')) { /* Regular Expression Compare? */
int *ovector = NULL;
static size_t sim_if_re_match_sub_count = 0;
re_buf = calloc (strlen (s2) + 1, 1);
re_buf = (char *)calloc (strlen (s2) + 1, 1);
if ((s2[0] == s2[strlen(s2)- 1]) && ((s2[0] == '\"') || (s2[0] == '\'')))
memcpy (re_buf, s2 + 1, strlen(s2)-2); /* extract string without surrounding quotes */
else
@@ -15542,7 +15542,7 @@ if (dptr != NULL) {
break;
}
explen = strlen (htext) + insert_size; /* size includes \0 since we're skipping the %A */
exptext = malloc (explen);
exptext = (char *)malloc (explen);
memcpy (exptext, htext, ep - htext);
if (addlevel > 0) { /* Need to find and adjust level indications */
const char *ins = insert_string;
@@ -17162,7 +17162,7 @@ MFileData (MFILE *f)
char *Data = NULL;
if (f != NULL) {
Data = malloc (f->pos + 1);
Data = (char *)malloc (f->pos + 1);
if (Data != NULL) {
memcpy (Data, f->buf, f->pos);
Data[f->pos] = '\0';

View File

@@ -180,7 +180,7 @@ int32 sim_int_char = 005; /* interrupt character *
int32 sim_dbg_int_char = 0; /* SIGINT char under debugger */
t_bool sim_dbg_signal = FALSE; /* Enable SIGINT to debugger */
static t_bool sim_running_under_debugger = FALSE;
static char *sim_controlling_debugger = NULL; /* gdb or lldb when sim_running_under_debugger is TRUE */
static const char *sim_controlling_debugger = NULL; /* gdb or lldb when sim_running_under_debugger is TRUE */
#define RUNNING_UNDER_GDB (sim_running_under_debugger && (strcmp (sim_controlling_debugger, "gdb") == 0))
#define RUNNING_UNDER_LLDB (sim_running_under_debugger && (strcmp (sim_controlling_debugger, "lldb") == 0))
static t_bool sigint_message_issued = FALSE;

View File

@@ -2667,11 +2667,11 @@ size_t list_size = 0;
snprintf (num, sizeof (num), "%s%d", (*line_list == NULL) ? "" : ", ", line_num + 1);
if (*line_list == NULL) {
list_size = strlen (num) + 1;
*line_list = calloc (list_size, 1);
*line_list = (char *)calloc (list_size, 1);
}
else {
list_size = strlen (*line_list) + strlen (num) + 1;
*line_list = realloc (*line_list, list_size);
*line_list = (char *)realloc (*line_list, list_size);
}
strlcat (*line_list, num, list_size);
}