mem_malloc type triviality checks (3/8)

```
git grep -l mem_malloc | xargs perl -i -lpe 's{\((\w+) \*\*\)mem_malloc\(sizeof\(\1 \*\) \* (\S+)\)}{mem_rmalloc<$1>($2)}'
```
This commit is contained in:
Jan Engelhardt 2024-08-30 14:15:31 +02:00
parent c7da9daee2
commit bb38a4a565
9 changed files with 23 additions and 23 deletions

View File

@ -668,9 +668,9 @@ void ConfigItem::Add(int count, ...) {
// we need count radiobuttons
// we need count IDs
m_tiCount = count;
m_tiList = (UITextItem **)mem_malloc(sizeof(UITextItem *) * m_tiCount);
m_tiList = mem_rmalloc<UITextItem *>(m_tiCount);
m_rbCount = count;
m_rbList = (UIRadioButton **)mem_malloc(sizeof(UIRadioButton *) * m_rbCount);
m_rbList = mem_rmalloc<UIRadioButton *>(m_rbCount);
m_iNumIDs = count;
m_iID = mem_rmalloc<int>(m_iNumIDs);
// make sure mallocs are ok
@ -721,7 +721,7 @@ void ConfigItem::Add(int count, ...) {
// we need 1 slider
// we need 1 ID
m_sCount = 1;
m_sList = (NewUISlider **)mem_malloc(sizeof(NewUISlider *) * 1);
m_sList = mem_rmalloc<NewUISlider *>(1);
m_iNumIDs = 1;
m_iID = mem_rmalloc<int>(1);
// make sure mallocs are ok
@ -761,9 +761,9 @@ void ConfigItem::Add(int count, ...) {
// we need 1 button
// we need 1 ID
m_bCount = 1;
m_bList = (NewUIButton **)mem_malloc(sizeof(NewUIButton *) * 1);
m_bList = mem_rmalloc<NewUIButton *>(1);
m_tiCount = 2;
m_tiList = (UITextItem **)mem_malloc(sizeof(UITextItem *) * 2);
m_tiList = mem_rmalloc<UITextItem *>(2);
m_iNumIDs = 1;
m_iID = mem_rmalloc<int>(1);
// make sure mallocs mallocs are ok
@ -798,9 +798,9 @@ void ConfigItem::Add(int count, ...) {
// we need 1 listbox
// we need 1 ID
m_lbCount = 1;
m_lbList = (NewUIListBox **)mem_malloc(sizeof(NewUIListBox *) * 1);
m_lbList = mem_rmalloc<NewUIListBox *>(1);
m_tiCount = count;
m_tiList = (UITextItem **)mem_malloc(sizeof(UITextItem *) * m_tiCount);
m_tiList = mem_rmalloc<UITextItem *>(m_tiCount);
m_iNumIDs = 1;
m_iID = mem_rmalloc<int>(1);
// make sure mallocs ok
@ -838,9 +838,9 @@ void ConfigItem::Add(int count, ...) {
// we need 1 button
// we need 1 ID
m_bCount = 1;
m_bList = (NewUIButton **)mem_malloc(sizeof(NewUIButton *) * 1);
m_bList = mem_rmalloc<NewUIButton *>(1);
m_tiCount = 2;
m_tiList = (UITextItem **)mem_malloc(sizeof(UITextItem *) * 2);
m_tiList = mem_rmalloc<UITextItem *>(2);
m_iNumIDs = 1;
m_iID = mem_rmalloc<int>(1);
// make sure mallocs mallocs are ok
@ -875,9 +875,9 @@ void ConfigItem::Add(int count, ...) {
// we need 1 hotspot
// we need 1 ID
m_hsCount = 1;
m_hsList = (UIHotspot **)mem_malloc(sizeof(UIHotspot *) * 1);
m_hsList = mem_rmalloc<UIHotspot *>(1);
m_tiCount = 4;
m_tiList = (UITextItem **)mem_malloc(sizeof(UITextItem *) * 4);
m_tiList = mem_rmalloc<UITextItem *>(4);
m_iNumIDs = 1;
m_iID = mem_rmalloc<int>(1);
// make sure mallocs are ok
@ -919,9 +919,9 @@ void ConfigItem::Add(int count, ...) {
// we need count radio buttons
// we need count IDs
m_tiCount = count;
m_tiList = (UITextItem **)mem_malloc(sizeof(UITextItem *) * m_tiCount);
m_tiList = mem_rmalloc<UITextItem *>(m_tiCount);
m_rbCount = count;
m_rbList = (UIRadioButton **)mem_malloc(sizeof(UIRadioButton *) * m_rbCount);
m_rbList = mem_rmalloc<UIRadioButton *>(m_rbCount);
m_iNumIDs = count;
m_iID = mem_rmalloc<int>(m_iNumIDs);
// make sure mallocs are ok

View File

@ -3135,7 +3135,7 @@ void ReadRoomAABBChunk(CFILE *fp, int version) {
Rooms[i].num_bbf_regions = cf_ReadShort(fp);
Rooms[i].num_bbf = mem_rmalloc<int16_t>(Rooms[i].num_bbf_regions);
Rooms[i].bbf_list = (int16_t **)mem_malloc(sizeof(int16_t *) * Rooms[i].num_bbf_regions);
Rooms[i].bbf_list = mem_rmalloc<int16_t *>(Rooms[i].num_bbf_regions);
Rooms[i].bbf_list_min_xyz = mem_rmalloc<vector>(Rooms[i].num_bbf_regions);
Rooms[i].bbf_list_max_xyz = mem_rmalloc<vector>(Rooms[i].num_bbf_regions);
Rooms[i].bbf_list_sector = (uint8_t *)mem_malloc(sizeof(char) * Rooms[i].num_bbf_regions);

View File

@ -480,7 +480,7 @@ void DebugGraph_DisplayOptions(void) {
bool exit_menu = false;
tGraphNode *node;
bool_values = (bool **)mem_malloc(sizeof(bool *) * graph_num_nodes);
bool_values = mem_rmalloc<bool *>(graph_num_nodes);
if (!bool_values)
return;

View File

@ -1556,7 +1556,7 @@ bool tMsgList::add(const char *msg, uint8_t lvl, uint8_t hr, uint8_t min, uint8_
m_limit = 64;
if (m_msg == NULL) {
m_msg = (char **)mem_malloc(sizeof(char *) * m_limit);
m_msg = mem_rmalloc<char *>(m_limit);
m_nmsg = 0;
}
@ -1669,7 +1669,7 @@ redo_copy:
}
ASSERT(c > 0);
m_conlines = (char **)mem_malloc(sizeof(char *) * c);
m_conlines = mem_rmalloc<char *>(c);
n_conlines = c;
memset(m_conlines, 0, sizeof(char *) * c);

View File

@ -180,7 +180,7 @@ int LoadStringTables(void) {
String_table_size = 0;
// malloc our array of char *
String_table = (char **)mem_malloc(sizeof(char *) * string_count);
String_table = mem_rmalloc<char *>(string_count);
if (!String_table) {
Localization_language = old_language;
return 0;
@ -324,7 +324,7 @@ try_english:
char **strtable;
// malloc our array of char *
*table = (char **)mem_malloc(sizeof(char *) * scount);
*table = mem_rmalloc<char *>(scount);
if (!*table) {
if (table)
*table = NULL;

View File

@ -1217,7 +1217,7 @@ bool MenuNewGame() {
#define OEM_MISSION_NAME "Descent 3: Sol Ascent"
#define OEM_TRAINING_NAME "Pilot Training "
n_missions = 2;
filelist = (char **)mem_malloc(sizeof(char *) * 2);
filelist = mem_rmalloc<char *>(2);
filelist[0] = mem_strdup(OEM_MISSION_FILE);
;
msn_lb->AddItem(OEM_MISSION_NAME);

View File

@ -315,7 +315,7 @@ void ddio_CleanPath(char *dest, const char *srcPath) {
}
// allocate the memory needed for the separate strings of each directory
directories = (char **)mem_malloc(sizeof(char *) * dirs);
directories = mem_rmalloc<char *>(dirs);
if (!directories) {
strcpy(dest, srcPath);
return;

View File

@ -394,7 +394,7 @@ void ddio_CleanPath(char *dest, const char *srcPath) {
}
// allocate the memory needed for the separate strings of each directory
directories = (char **)mem_malloc(sizeof(char *) * dirs);
directories = mem_rmalloc<char *>(dirs);
if (!directories) {
strcpy(dest, srcPath);
return;

View File

@ -9442,7 +9442,7 @@ int CDallasMainDlg::ParseCustomScriptFile(char *filename, bool show_errors /*=TR
ClearCustomScriptStorage();
m_MaxNumCustomScriptLines = CountCustomScriptLines(infile);
if (m_MaxNumCustomScriptLines > 0) {
m_CustomScriptLines = (char **)mem_malloc(sizeof(char *) * m_MaxNumCustomScriptLines);
m_CustomScriptLines = mem_rmalloc<char *>(m_MaxNumCustomScriptLines);
if (m_CustomScriptLines == NULL) {
MessageBox("ERROR: Ran out of memory allocating custom script block", "Custom Script Parse Error",
MB_OK | MB_ICONEXCLAMATION);