From d6a53f1c06820dee5233788d387f7f10731fd54c Mon Sep 17 00:00:00 2001 From: Mark Pizzolato Date: Fri, 24 Oct 2025 08:19:42 -1000 Subject: [PATCH] SCP: Cleanup allocated memory assignments for C++ compatibility --- scp.c | 8 ++++---- sim_console.c | 2 +- sim_fio.c | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/scp.c b/scp.c index 9e02f506..217dcd46 100644 --- a/scp.c +++ b/scp.c @@ -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'; diff --git a/sim_console.c b/sim_console.c index 9c680624..921b6bbe 100644 --- a/sim_console.c +++ b/sim_console.c @@ -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; diff --git a/sim_fio.c b/sim_fio.c index a835103f..021dfc87 100644 --- a/sim_fio.c +++ b/sim_fio.c @@ -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); }