diff --git a/Descent3/Briefing.cpp b/Descent3/Briefing.cpp index 9edaa83e..09c36bcb 100644 --- a/Descent3/Briefing.cpp +++ b/Descent3/Briefing.cpp @@ -305,7 +305,7 @@ bool ParseForHotTags(const char *src, char **dest) { int curr_size = length; int curr_index = 0; - dest_ptr = *dest = (char *)mem_malloc(length); + dest_ptr = *dest = mem_rmalloc(length); if (!dest_ptr) return false; char replacement[256]; diff --git a/Descent3/Inventory.cpp b/Descent3/Inventory.cpp index 948cf0e0..575fa668 100644 --- a/Descent3/Inventory.cpp +++ b/Descent3/Inventory.cpp @@ -581,7 +581,7 @@ bool Inventory::AddCounterMeasure(int id, int aux_type, int aux_id, int flags, c if (Weapons[id].icon_handle >= 0) { newnode->icon_name = - (char *)mem_malloc(strlen(GameBitmaps[GameTextures[Weapons[id].icon_handle].bm_handle].name) + 1); + mem_rmalloc(strlen(GameBitmaps[GameTextures[Weapons[id].icon_handle].bm_handle].name) + 1); strcpy(newnode->icon_name, GameBitmaps[GameTextures[Weapons[id].icon_handle].bm_handle].name); } else { newnode->icon_name = nullptr; @@ -647,7 +647,7 @@ bool Inventory::AddObjectItem(int otype, int oid, int oauxt, int oauxi, int flag newnode->oid = oauxi; if (Object_info[oid].description) { - newnode->description = (char *)mem_malloc(strlen(Object_info[oid].description) + 1); + newnode->description = mem_rmalloc(strlen(Object_info[oid].description) + 1); strcpy(newnode->description, Object_info[oid].description); } else { newnode->description = mem_rmalloc(); @@ -672,7 +672,7 @@ bool Inventory::AddObjectItem(int otype, int oid, int oauxt, int oauxi, int flag if (flags & INVAF_LEVELLAST) newnode->iflags |= INVAF_LEVELLAST; - newnode->icon_name = (char *)mem_malloc(strlen(Object_info[oid].icon_name) + 1); + newnode->icon_name = mem_rmalloc(strlen(Object_info[oid].icon_name) + 1); strcpy(newnode->icon_name, Object_info[oid].icon_name); if (description) { diff --git a/Descent3/LoadLevel.cpp b/Descent3/LoadLevel.cpp index f38d3517..411e8ed2 100644 --- a/Descent3/LoadLevel.cpp +++ b/Descent3/LoadLevel.cpp @@ -1686,7 +1686,7 @@ int ReadObject(CFILE *ifile, object *objp, int handle, int fileversion) { // Set the name if (tempname[0]) { - objp->name = (char *)mem_malloc(strlen(tempname) + 1); + objp->name = mem_rmalloc(strlen(tempname) + 1); strcpy(objp->name, tempname); } @@ -2446,7 +2446,7 @@ int ReadRoom(CFILE *ifile, room *rp, int version) { char tempname[ROOM_NAME_LEN + 1]; cf_ReadString(tempname, sizeof(tempname), ifile); if (strlen(tempname)) { - rp->name = (char *)mem_malloc(strlen(tempname) + 1); + rp->name = mem_rmalloc(strlen(tempname) + 1); strcpy(rp->name, tempname); } } diff --git a/Descent3/TelComEffects.cpp b/Descent3/TelComEffects.cpp index 629d14af..efccb0a7 100644 --- a/Descent3/TelComEffects.cpp +++ b/Descent3/TelComEffects.cpp @@ -1030,13 +1030,13 @@ bool CreateTextStatic(tceffect *tce, const char *text) { if (!text) return false; - tce->text_buffer = (char *)mem_malloc(strlen(text) + 10); + tce->text_buffer = mem_rmalloc(strlen(text) + 10); if (!tce->text_buffer) return false; tce->alpha = 255; - char *tempbuffer = (char *)mem_malloc(strlen(text) + 10); + char *tempbuffer = mem_rmalloc(strlen(text) + 10); if (!tempbuffer) return false; strcpy(tempbuffer, text); @@ -1053,11 +1053,11 @@ bool CreateTextFade(tceffect *tce, const char *text) { ASSERT(text); if (!text || text[0] == '\0') return false; - tce->text_buffer = (char *)mem_malloc(strlen(text) + 10); + tce->text_buffer = mem_rmalloc(strlen(text) + 10); if (!tce->text_buffer) return false; - char *tempbuffer = (char *)mem_malloc(strlen(text) + 10); + char *tempbuffer = mem_rmalloc(strlen(text) + 10); if (!tempbuffer) return false; strcpy(tempbuffer, text); @@ -1084,11 +1084,11 @@ bool CreateTextType(tceffect *tce, const char *text) { ASSERT(text); if (!text || text[0] == '\0') return false; - tce->text_buffer = (char *)mem_malloc(strlen(text) + 10); + tce->text_buffer = mem_rmalloc(strlen(text) + 10); if (!tce->text_buffer) return false; - char *tempbuffer = (char *)mem_malloc(strlen(text) + 10); + char *tempbuffer = mem_rmalloc(strlen(text) + 10); if (!tempbuffer) return false; strcpy(tempbuffer, text); @@ -1252,7 +1252,7 @@ bool CreateMovie(tceffect *tce, const char *filename) { tce->movieinfo.filename = NULL; tce->w = tce->h = 100; - tce->movieinfo.filename = (char *)mem_malloc(strlen(filename) + 1); + tce->movieinfo.filename = mem_rmalloc(strlen(filename) + 1); if (!tce->movieinfo.filename) return false; strcpy(tce->movieinfo.filename, filename); diff --git a/Descent3/demofile.cpp b/Descent3/demofile.cpp index 86f7924f..2024500e 100644 --- a/Descent3/demofile.cpp +++ b/Descent3/demofile.cpp @@ -1693,7 +1693,7 @@ void DemoReadPersistantHUDMessage() { flags = cf_ReadInt(Demo_cfp); sound_index = cf_ReadInt(Demo_cfp); int msglen = cf_ReadShort(Demo_cfp); - fmt = (char *)mem_malloc(msglen); + fmt = mem_rmalloc(msglen); cf_ReadBytes((uint8_t *)fmt, msglen, Demo_cfp); AddPersistentHUDMessage(color, x, y, time, flags, sound_index, fmt); mem_free(fmt); diff --git a/Descent3/hotspotmap.cpp b/Descent3/hotspotmap.cpp index 5009d7b5..edb1b408 100644 --- a/Descent3/hotspotmap.cpp +++ b/Descent3/hotspotmap.cpp @@ -721,7 +721,7 @@ void menutga_LoadHotSpotMap(int back_bmp, const char *filename, hotspotmap_t *hs // left top size = ((wndmap->wm[count].l_end_x) - (wndmap->wm[count].l_start_x)) * ((wndmap->wm[count].t_bottom_y) - (wndmap->wm[count].t_top_y)); - wndmap->wm[count].lt = (char *)mem_malloc(size); + wndmap->wm[count].lt = mem_rmalloc(size); for (index = 0; index < size; index++) { wndmap->wm[count].lt[index] = cf_ReadByte(infile); } @@ -729,7 +729,7 @@ void menutga_LoadHotSpotMap(int back_bmp, const char *filename, hotspotmap_t *hs // right top size = ((wndmap->wm[count].r_end_x) - (wndmap->wm[count].r_start_x)) * ((wndmap->wm[count].t_bottom_y) - (wndmap->wm[count].t_top_y)); - wndmap->wm[count].rt = (char *)mem_malloc(size); + wndmap->wm[count].rt = mem_rmalloc(size); for (index = 0; index < size; index++) { wndmap->wm[count].rt[index] = cf_ReadByte(infile); } @@ -739,14 +739,14 @@ void menutga_LoadHotSpotMap(int back_bmp, const char *filename, hotspotmap_t *hs // left bottom size = ((wndmap->wm[count].l_end_x) - (wndmap->wm[count].l_start_x)) * ((wndmap->wm[count].b_bottom_y) - (wndmap->wm[count].b_top_y)); - wndmap->wm[count].lb = (char *)mem_malloc(size); + wndmap->wm[count].lb = mem_rmalloc(size); for (index = 0; index < size; index++) { wndmap->wm[count].lb[index] = cf_ReadByte(infile); } // right bottom size = ((wndmap->wm[count].r_end_x) - (wndmap->wm[count].r_start_x)) * ((wndmap->wm[count].b_bottom_y) - (wndmap->wm[count].b_top_y)); - wndmap->wm[count].rb = (char *)mem_malloc(size); + wndmap->wm[count].rb = mem_rmalloc(size); for (index = 0; index < size; index++) { wndmap->wm[count].rb[index] = cf_ReadByte(infile); } @@ -872,7 +872,7 @@ bool menutga_ConvertTGAtoHSM(const char *fpath) { } int size = strlen(filename) + 5; - menu_filename = (char *)mem_malloc(size); + menu_filename = mem_rmalloc(size); strcpy(menu_filename, filename); strcat(menu_filename, ".HSM"); // Hot Spot Map LOG_DEBUG.printf("HSM=%s", menu_filename); diff --git a/Descent3/hud.cpp b/Descent3/hud.cpp index f6b90bf8..fc47e9ba 100644 --- a/Descent3/hud.cpp +++ b/Descent3/hud.cpp @@ -840,7 +840,7 @@ void InitHUDItem(int new_item, tHUDItem *item) { break; case HUD_ITEM_CUSTOMTEXT2: // malloc buffer to be updated later - HUD_array[new_item].data.text = (char *)mem_malloc(item->buffer_size); + HUD_array[new_item].data.text = mem_rmalloc(item->buffer_size); HUD_array[new_item].data.text[0] = 0; HUD_array[new_item].buffer_size = item->buffer_size; stat = STAT_CUSTOM; @@ -998,7 +998,7 @@ bool LGSHudState(CFILE *fp) { huditem.render_fn = NULL; // use pointer to function void (*fn)(struct tHUDItem *) AddHUDItem(&huditem); - buffer = (char *)mem_malloc(huditem.buffer_size); + buffer = mem_rmalloc(huditem.buffer_size); cf_ReadString(buffer, huditem.buffer_size, fp); UpdateCustomtext2HUDItem(buffer); mem_free(buffer); diff --git a/Descent3/hudmessage.cpp b/Descent3/hudmessage.cpp index 8202d571..fd2648ea 100644 --- a/Descent3/hudmessage.cpp +++ b/Descent3/hudmessage.cpp @@ -1628,7 +1628,7 @@ bool MsgListConsole::Open(const char *title, int x, int y, int w, int h) { m_buflen = 2048; redo_copy: - m_buffer = (char *)mem_malloc(m_buflen); + m_buffer = mem_rmalloc(m_buflen); if (m_buffer) { m_buffer[0] = 0; m_opened = true; diff --git a/Descent3/levelgoal.cpp b/Descent3/levelgoal.cpp index d5cd687f..80e6f3f4 100644 --- a/Descent3/levelgoal.cpp +++ b/Descent3/levelgoal.cpp @@ -288,7 +288,7 @@ bool lgoal::SetName(int handle, char *name) { if (m_name) mem_free(m_name); - m_name = (char *)mem_malloc(strlen(name) + 1); + m_name = mem_rmalloc(strlen(name) + 1); strcpy(m_name, name); m_modified = 1; @@ -320,7 +320,7 @@ bool lgoal::SetCompletionMessage(char *message) { if (m_completion_message) mem_free(m_completion_message); - m_completion_message = (char *)mem_malloc(strlen(message) + 1); + m_completion_message = mem_rmalloc(strlen(message) + 1); strcpy(m_completion_message, message); return true; @@ -333,7 +333,7 @@ bool lgoal::SetItemName(char *iname) { if (m_item_name) mem_free(m_item_name); - m_item_name = (char *)mem_malloc(strlen(iname) + 1); + m_item_name = mem_rmalloc(strlen(iname) + 1); strcpy(m_item_name, iname); return true; @@ -442,7 +442,7 @@ bool lgoal::SetDesc(char *desc) { if (m_desc) mem_free(m_desc); - m_desc = (char *)mem_malloc(strlen(desc) + 1); + m_desc = mem_rmalloc(strlen(desc) + 1); strcpy(m_desc, desc); return true; diff --git a/Descent3/localization.cpp b/Descent3/localization.cpp index 3b37244a..1e89a2b5 100644 --- a/Descent3/localization.cpp +++ b/Descent3/localization.cpp @@ -667,7 +667,7 @@ void GrowString::operator+=(char *str) { node = mem_rmalloc(); if (!node) return; - node->string_data = (char *)mem_malloc(strlen(str) + 2); + node->string_data = mem_rmalloc(strlen(str) + 2); if (!node->string_data) { mem_free(node); return; @@ -677,7 +677,7 @@ void GrowString::operator+=(char *str) { node->next = NULL; curr = node; } else { - root.string_data = (char *)mem_malloc(strlen(str) + 1); + root.string_data = mem_rmalloc(strlen(str) + 1); if (!root.string_data) return; strcpy(root.string_data, str); diff --git a/Descent3/multi_ui.cpp b/Descent3/multi_ui.cpp index 8e6ba477..facde1fb 100644 --- a/Descent3/multi_ui.cpp +++ b/Descent3/multi_ui.cpp @@ -725,7 +725,7 @@ void DoMultiAllowed(void) { bool objsallowed[MAX_OBJECTS]; ConfigItem **ship_list = NULL; size_t strMax = std::max(strlen(TXT_ALLOW), strlen(TXT_DISALLOW)) + 3; - char *str = (char *)mem_malloc(strMax); + char *str = mem_rmalloc(strMax); // Create Text Items and Window UITextItem cancel_on_text(TXT_CANCEL, UICOL_HOTSPOT_HI); diff --git a/Descent3/subtitles.cpp b/Descent3/subtitles.cpp index ea21ff21..34d73cd3 100644 --- a/Descent3/subtitles.cpp +++ b/Descent3/subtitles.cpp @@ -186,7 +186,7 @@ void SubtParseSubtitles(CFILE *file) { Subtitles[Num_subtitles].first_frame = first_frame; Subtitles[Num_subtitles].last_frame = last_frame; - Subtitles[Num_subtitles].msg = (char *)mem_malloc(strlen(p) + 1); + Subtitles[Num_subtitles].msg = mem_rmalloc(strlen(p) + 1); if (!Subtitles[Num_subtitles].msg) goto subt_parse_error; strcpy(Subtitles[Num_subtitles].msg, p); // be sure to free this later diff --git a/bitmap/tga.cpp b/bitmap/tga.cpp index d12a00fa..515a7b1f 100644 --- a/bitmap/tga.cpp +++ b/bitmap/tga.cpp @@ -503,7 +503,7 @@ int bm_tga_alloc_file(CFILE *infile, char *name, int format) { cfseek(infile, savepos, SEEK_SET); - Tga_file_data = (char *)mem_malloc(numleft); + Tga_file_data = mem_rmalloc(numleft); ASSERT(Tga_file_data != NULL); Fake_pos = 0; Bad_tga = 0; @@ -661,7 +661,7 @@ int bm_page_in_file(int n) { cfseek(infile, savepos, SEEK_SET); - Tga_file_data = (char *)mem_malloc(numleft); + Tga_file_data = mem_rmalloc(numleft); ASSERT(Tga_file_data != NULL); Fake_pos = 0; Bad_tga = 0; diff --git a/ddebug/windebug.cpp b/ddebug/windebug.cpp index a3bccfba..c1e2fcef 100644 --- a/ddebug/windebug.cpp +++ b/ddebug/windebug.cpp @@ -239,7 +239,7 @@ int Debug_ErrorBox(int type, const char *title, const char *topstring, const cha else debug_break(); - char *tmpbuf = (char *)mem_malloc(strlen(topstring) + strlen(bottomstring) + 5); + char *tmpbuf = mem_rmalloc(strlen(topstring) + strlen(bottomstring) + 5); wsprintf(tmpbuf, "%s\r\n\r\n%s", topstring, bottomstring); ShowCursor(TRUE); diff --git a/ddio/winfile.cpp b/ddio/winfile.cpp index 602e1553..7df2c836 100644 --- a/ddio/winfile.cpp +++ b/ddio/winfile.cpp @@ -302,7 +302,7 @@ int ddio_GetFileSysRoots(char **roots, int max_roots) { while ((count < max_roots) && (!done)) { if (*strptr != 0) { strsize = strlen(strptr); - string = roots[count] = (char *)mem_malloc(strsize); + string = roots[count] = mem_rmalloc(strsize); if (!string) break; // remove the trailing \ from windows @@ -336,7 +336,7 @@ std::vector ddio_GetSysRoots() { while (!done) { if (*strptr != 0) { strsize = strlen(strptr); - string = (char *)mem_malloc(strsize); + string = mem_rmalloc(strsize); if (!string) break; // remove the trailing \ from windows diff --git a/editor/BriefEdit.cpp b/editor/BriefEdit.cpp index b2dc8e6a..d6aaf618 100644 --- a/editor/BriefEdit.cpp +++ b/editor/BriefEdit.cpp @@ -739,7 +739,7 @@ void BEAddTextEffect(TCTEXTDESC *desc, char *text, char *description, int id) { mem_free(befx->text); befx->text = NULL; } - befx->text = (char *)mem_malloc(strlen(text) + 1); + befx->text = mem_rmalloc(strlen(text) + 1); ASSERT(befx->text); strcpy(befx->text, text); @@ -1407,7 +1407,7 @@ void CBriefEdit::OnBriefEffectEdit() { if (Briefing_screens[scr_index].effects[efx_index].text) mem_free(Briefing_screens[scr_index].effects[efx_index].text); - Briefing_screens[scr_index].effects[efx_index].text = (char *)mem_malloc(dlg.m_Text.GetLength() + 1); + Briefing_screens[scr_index].effects[efx_index].text = mem_rmalloc(dlg.m_Text.GetLength() + 1); ASSERT(Briefing_screens[scr_index].effects[efx_index].text); if (Briefing_screens[scr_index].effects[efx_index].text) { @@ -1651,7 +1651,7 @@ void CBriefEdit::OnBriefEffectText() { if (Briefing_screens[c_scr].effects[c_eff].text) mem_free(Briefing_screens[c_scr].effects[c_eff].text); - Briefing_screens[c_scr].effects[c_eff].text = (char *)mem_malloc(dlg.m_Text.GetLength() + 1); + Briefing_screens[c_scr].effects[c_eff].text = mem_rmalloc(dlg.m_Text.GetLength() + 1); ASSERT(Briefing_screens[c_scr].effects[c_eff].text); if (Briefing_screens[c_scr].effects[c_eff].text) { diff --git a/editor/DallasMainDlg.cpp b/editor/DallasMainDlg.cpp index 97002434..2453d1eb 100644 --- a/editor/DallasMainDlg.cpp +++ b/editor/DallasMainDlg.cpp @@ -4980,7 +4980,7 @@ int CDallasMainDlg::AddDoorToList(char *name) { return FALSE; int pos = m_DoorListSize; - m_DoorList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_DoorList[pos] = mem_rmalloc(strlen(name) + 1); if (m_DoorList[pos] == NULL) { MessageBox("Out of memory in AddDoorToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5018,7 +5018,7 @@ int CDallasMainDlg::AddObjectToList(char *name) { return FALSE; int pos = m_ObjectListSize; - m_ObjectList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_ObjectList[pos] = mem_rmalloc(strlen(name) + 1); if (m_ObjectList[pos] == NULL) { MessageBox("Out of memory in AddObjectToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5056,7 +5056,7 @@ int CDallasMainDlg::AddRoomToList(char *name) { return FALSE; int pos = m_RoomListSize; - m_RoomList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_RoomList[pos] = mem_rmalloc(strlen(name) + 1); if (m_RoomList[pos] == NULL) { MessageBox("Out of memory in AddRoomToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5094,7 +5094,7 @@ int CDallasMainDlg::AddTriggerToList(char *name) { return FALSE; int pos = m_TriggerListSize; - m_TriggerList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_TriggerList[pos] = mem_rmalloc(strlen(name) + 1); if (m_TriggerList[pos] == NULL) { MessageBox("Out of memory in AddTriggerToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5132,7 +5132,7 @@ int CDallasMainDlg::AddSoundToList(char *name) { return FALSE; int pos = m_SoundListSize; - m_SoundList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_SoundList[pos] = mem_rmalloc(strlen(name) + 1); if (m_SoundList[pos] == NULL) { MessageBox("Out of memory in AddSoundToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5170,7 +5170,7 @@ int CDallasMainDlg::AddTextureToList(char *name) { return FALSE; int pos = m_TextureListSize; - m_TextureList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_TextureList[pos] = mem_rmalloc(strlen(name) + 1); if (m_TextureList[pos] == NULL) { MessageBox("Out of memory in AddTextureToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5208,7 +5208,7 @@ int CDallasMainDlg::AddSpecnameToList(char *name) { return FALSE; int pos = m_SpecnameListSize; - m_SpecnameList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_SpecnameList[pos] = mem_rmalloc(strlen(name) + 1); if (m_SpecnameList[pos] == NULL) { MessageBox("Out of memory in AddSpecnameToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5246,7 +5246,7 @@ int CDallasMainDlg::AddPathToList(char *name) { return FALSE; int pos = m_PathListSize; - m_PathList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_PathList[pos] = mem_rmalloc(strlen(name) + 1); if (m_PathList[pos] == NULL) { MessageBox("Out of memory in AddPathToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5284,7 +5284,7 @@ int CDallasMainDlg::AddMatcenToList(char *name) { return FALSE; int pos = m_MatcenListSize; - m_MatcenList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_MatcenList[pos] = mem_rmalloc(strlen(name) + 1); if (m_MatcenList[pos] == NULL) { MessageBox("Out of memory in AddMatcenToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5322,7 +5322,7 @@ int CDallasMainDlg::AddGoalToList(char *name) { return FALSE; int pos = m_GoalListSize; - m_GoalList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_GoalList[pos] = mem_rmalloc(strlen(name) + 1); if (m_GoalList[pos] == NULL) { MessageBox("Out of memory in AddGoalToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5360,7 +5360,7 @@ int CDallasMainDlg::AddStrmAudioToList(char *name) { return FALSE; int pos = m_StrmAudioListSize; - m_StrmAudioList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_StrmAudioList[pos] = mem_rmalloc(strlen(name) + 1); if (m_StrmAudioList[pos] == NULL) { MessageBox("Out of memory in AddStrmAudioToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5398,7 +5398,7 @@ int CDallasMainDlg::AddMessageNameToList(char *name) { return FALSE; int pos = m_MessageNameListSize; - m_MessageNameList[pos] = (char *)mem_malloc(strlen(name) + 1); + m_MessageNameList[pos] = mem_rmalloc(strlen(name) + 1); if (m_MessageNameList[pos] == NULL) { MessageBox("Out of memory in AddMessageNameToList()!", "Error!", MB_OK | MB_ICONEXCLAMATION); return FALSE; @@ -5512,7 +5512,7 @@ int CDallasMainDlg::AddUserTypeValue(char *utype_name, char *value_name) { // Store the new value at the current position tEnumValueEntry *value_entry = &entry->values[j]; value_entry->value = new_value; - value_entry->name = (char *)mem_malloc(strlen(value_name) + 1); + value_entry->name = mem_rmalloc(strlen(value_name) + 1); if (value_entry->name == NULL) { MessageBox("ERROR: Out of mem in AddUserTypeValue()!", "Error!"); return (-1); @@ -5582,7 +5582,7 @@ int CDallasMainDlg::ChangeValueName(char *utype_name, char *old_name, char *new_ mem_free(value_entry->name); // Add the new name - value_entry->name = (char *)mem_malloc(strlen(new_name) + 1); + value_entry->name = mem_rmalloc(strlen(new_name) + 1); if (value_entry->name == NULL) { MessageBox("ERROR: Out of mem in ChangeValueName()!", "Error!"); return FALSE; @@ -6185,7 +6185,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* done = 1; else if (m_NumFunctionCategories < MAX_CATEGORIES) { if (GetFunctionCategoryID(line) == INVALID_CATEGORY) { // don't add duplicate categories - m_FunctionCategories[m_NumFunctionCategories] = (char *)mem_malloc(strlen(line) + 1); + m_FunctionCategories[m_NumFunctionCategories] = mem_rmalloc(strlen(line) + 1); if (m_FunctionCategories[m_NumFunctionCategories] == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6222,7 +6222,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* enum_entry = NULL; } else { enum_entry = &m_EnumDatabase[m_NumEnums++]; - enum_entry->name = (char *)mem_malloc(strlen(enum_name) + 1); + enum_entry->name = mem_rmalloc(strlen(enum_name) + 1); if (enum_entry->name == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6240,7 +6240,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* // Add the default (-1:None) value tEnumValueEntry *value_entry; value_entry = &enum_entry->values[enum_entry->num_values++]; - value_entry->name = (char *)mem_malloc(strlen(USERTYPE_NONE) + 1); + value_entry->name = mem_rmalloc(strlen(USERTYPE_NONE) + 1); if (value_entry->name == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6266,7 +6266,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* enum_entry = NULL; } else { enum_entry = &m_EnumDatabase[m_NumEnums++]; - enum_entry->name = (char *)mem_malloc(strlen(enum_name) + 1); + enum_entry->name = mem_rmalloc(strlen(enum_name) + 1); if (enum_entry->name == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6313,7 +6313,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* value_entry = NULL; } else { value_entry = &enum_entry->values[enum_entry->num_values++]; - value_entry->name = (char *)mem_malloc(strlen(enum_value_name) + 1); + value_entry->name = mem_rmalloc(strlen(enum_value_name) + 1); if (value_entry->name == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6345,7 +6345,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* flag_entry = NULL; } else { flag_entry = &m_FlagDatabase[m_NumFlags++]; - flag_entry->name = (char *)mem_malloc(strlen(flag_name) + 1); + flag_entry->name = mem_rmalloc(strlen(flag_name) + 1); if (flag_entry->name == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6390,7 +6390,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* value_entry = NULL; } else { value_entry = &flag_entry->values[flag_entry->num_values++]; - value_entry->name = (char *)mem_malloc(strlen(flag_value_name) + 1); + value_entry->name = mem_rmalloc(strlen(flag_value_name) + 1); if (value_entry->name == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6439,7 +6439,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* RemoveTrailingWhitespace(linebuf); line = SkipInitialWhitespace(linebuf); - action->desc = (char *)mem_malloc(strlen(line) + 1); + action->desc = mem_rmalloc(strlen(line) + 1); if (action->desc == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6455,7 +6455,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* RemoveTrailingWhitespace(linebuf); line = SkipInitialWhitespace(linebuf); - action->func = (char *)mem_malloc(strlen(line) + 1); + action->func = mem_rmalloc(strlen(line) + 1); if (action->func == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6487,7 +6487,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* if (!done) FunctionFileParseError(UEOF_ERR, linenum, filename); - action->help = (char *)mem_malloc(strlen(helpbuf) + 1); + action->help = mem_rmalloc(strlen(helpbuf) + 1); if (action->help == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6528,7 +6528,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* RemoveTrailingWhitespace(linebuf); line = SkipInitialWhitespace(linebuf); - query->desc = (char *)mem_malloc(strlen(line) + 1); + query->desc = mem_rmalloc(strlen(line) + 1); if (query->desc == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6544,7 +6544,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* RemoveTrailingWhitespace(linebuf); line = SkipInitialWhitespace(linebuf); - query->func = (char *)mem_malloc(strlen(line) + 1); + query->func = mem_rmalloc(strlen(line) + 1); if (query->func == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6576,7 +6576,7 @@ void CDallasMainDlg::ParseFunctionFile(char *filename, bool show_errors /*=TRUE* if (!done) FunctionFileParseError(UEOF_ERR, linenum, filename); - query->help = (char *)mem_malloc(strlen(helpbuf) + 1); + query->help = mem_rmalloc(strlen(helpbuf) + 1); if (query->help == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(ifile); @@ -6772,7 +6772,7 @@ bool CDallasMainDlg::ValidateActionNode(HTREEITEM node, int linenum) child_node=m_ScriptTree.GetChildItem(node); // Make a copy of description (so null chars can be added) - desc_copy=(char *)mem_malloc(strlen(desc)+1); + desc_copy=mem_rmalloc(strlen(desc)+1); if(desc_copy==NULL) { MessageBox("ERROR: Out of memory in ValidateActionNode()!","Out of Memory Error!",MB_OK|MB_ICONEXCLAMATION); return FALSE; @@ -7047,7 +7047,7 @@ bool CDallasMainDlg::ValidateQueryNode(HTREEITEM node, int linenum) child_node=m_ScriptTree.GetChildItem(node); // Make a copy of description (so null chars can be added) - desc_copy=(char *)mem_malloc(strlen(desc)+1); + desc_copy=mem_rmalloc(strlen(desc)+1); if(desc_copy==NULL) { MessageBox("ERROR: Out of memory in ValidateQueryNode()!","Out of Memory Error!",MB_OK|MB_ICONEXCLAMATION); return FALSE; @@ -7137,7 +7137,7 @@ void CDallasMainDlg::FillActionMenu(CMenu *action_menu, int command_offset) { // Scan the list, adding Actions that match the current category for (k = 0; k < m_NumActions; k++) if (m_ActionDatabase[k].category == j) { - char *temp_desc = (char *)mem_malloc(strlen(m_ActionDatabase[k].desc) + 1); + char *temp_desc = mem_rmalloc(strlen(m_ActionDatabase[k].desc) + 1); if (temp_desc == NULL) { MessageBox("Out of memory error in FillActionMenu()!", "Memory Error!", MB_OK | MB_ICONEXCLAMATION); return; @@ -7175,7 +7175,7 @@ void CDallasMainDlg::FillQueryMenu(CMenu *query_menu, int command_offset, int va // Scan the list, adding queries that match the current category for (k = 0; k < m_NumActions; k++) if (m_QueryDatabase[k].category == j) { - char *temp_desc = (char *)mem_malloc(strlen(m_QueryDatabase[k].desc) + 1); + char *temp_desc = mem_rmalloc(strlen(m_QueryDatabase[k].desc) + 1); if (temp_desc == NULL) { MessageBox("Out of memory error in FillQueryMenu()!", "Memory Error!", MB_OK | MB_ICONEXCLAMATION); return; @@ -7848,7 +7848,7 @@ int CDallasMainDlg::ParseSourceScript(char *filename) { value_entry = NULL; } else { value_entry = &enum_entry->values[enum_entry->num_values++]; - value_entry->name = (char *)mem_malloc(strlen(enum_value_name) + 1); + value_entry->name = mem_rmalloc(strlen(enum_value_name) + 1); if (value_entry->name == NULL) { FunctionFileParseError(NO_MEM_ERR, linenum, filename); cfclose(infile); @@ -9466,7 +9466,7 @@ int CDallasMainDlg::ParseCustomScriptFile(char *filename, bool show_errors /*=TR // Store this line if (m_NumCustomScriptLines < m_MaxNumCustomScriptLines) { - m_CustomScriptLines[m_NumCustomScriptLines] = (char *)mem_malloc(strlen(linebuf) + 1); + m_CustomScriptLines[m_NumCustomScriptLines] = mem_rmalloc(strlen(linebuf) + 1); if (m_CustomScriptLines[m_NumCustomScriptLines] == NULL) { MessageBox("ERROR: Ran out of memory parsing custom script block", "Custom Script Parse Error", MB_OK | MB_ICONEXCLAMATION); @@ -13737,7 +13737,7 @@ void CDallasMainDlg::AddActionParameterNodes(HTREEITEM action_node) if(desc==NULL) return; // Make a copy of description (so null chars can be added) - desc_copy=(char *)mem_malloc(strlen(desc)+1); + desc_copy=mem_rmalloc(strlen(desc)+1); if(desc_copy==NULL) { MessageBox("ERROR: Out of memory adding action parameter node!","Out of Memory Error!",MB_OK|MB_ICONEXCLAMATION); return; @@ -13857,7 +13857,7 @@ void CDallasMainDlg::AddQueryParameterNodes(HTREEITEM query_node) if(desc==NULL) return; // Make a copy of description (so null chars can be added) - desc_copy=(char *)mem_malloc(strlen(desc)+1); + desc_copy=mem_rmalloc(strlen(desc)+1); if(desc_copy==NULL) { MessageBox("ERROR: Out of memory adding query parameter node!","Out of Memory Error!",MB_OK|MB_ICONEXCLAMATION); return; diff --git a/editor/FilePageAddDlg.cpp b/editor/FilePageAddDlg.cpp index 1e3e04fb..84799f06 100644 --- a/editor/FilePageAddDlg.cpp +++ b/editor/FilePageAddDlg.cpp @@ -282,7 +282,7 @@ inline void CFileList::setPath(CString path) { if (temp.Right(1) != "\\") temp += "\\"; - buffer = (char *)mem_malloc(temp.GetLength() + 1); + buffer = mem_rmalloc(temp.GetLength() + 1); if (!buffer) return; diff --git a/editor/MainFrm.cpp b/editor/MainFrm.cpp index e8b994f8..c12cdf38 100644 --- a/editor/MainFrm.cpp +++ b/editor/MainFrm.cpp @@ -3171,7 +3171,7 @@ void CMainFrame::OnHotspotTga() { return; } - buffer = (char *)mem_malloc(strlen(tga_path.GetBuffer(1)) + 1); + buffer = mem_rmalloc(strlen(tga_path.GetBuffer(1)) + 1); if (!buffer) { Int3(); // find Jeff return; diff --git a/editor/MegacellDialog.cpp b/editor/MegacellDialog.cpp index fdc5ef2d..bbc8dc4e 100644 --- a/editor/MegacellDialog.cpp +++ b/editor/MegacellDialog.cpp @@ -375,7 +375,7 @@ void CMegacellDialog::OnDeleteMegacell() { uint16_t texindices[MAX_MEGACELL_WIDTH * MAX_MEGACELL_HEIGHT]; for (i = 0; i < MAX_MEGACELL_WIDTH * MAX_MEGACELL_HEIGHT; i++) { - texnames[i] = (char *)mem_malloc(PAGENAME_LEN); + texnames[i] = mem_rmalloc(PAGENAME_LEN); ASSERT(texnames[i]); if (!can_delete[i]) continue; diff --git a/editor/ObjCScript.cpp b/editor/ObjCScript.cpp index ae349e82..ccf75dd8 100644 --- a/editor/ObjCScript.cpp +++ b/editor/ObjCScript.cpp @@ -239,7 +239,7 @@ char *LoadScript(const char *filename) { cfclose(file); - source = (char *)mem_malloc(strlen(temp.GetBuffer(1)) + 1); + source = mem_rmalloc(strlen(temp.GetBuffer(1)) + 1); if (!source) return false; strcpy(source, temp.GetBuffer(1)); @@ -604,7 +604,7 @@ char *AddScriptBlockToScript(char *script, const char *newname, const char *type sprintf(newhdr, SCRHDR_FORMAT, type_str, newname); sprintf(newblk, SCRIPT_FORMAT, newname, newhdr); - newsrc = (char *)mem_malloc(strlen(script) + strlen(newblk) + 1); + newsrc = mem_rmalloc(strlen(script) + strlen(newblk) + 1); if (!newsrc) { mprintf(1, "Allocation failure in creating new script buffer.\n"); return NULL; @@ -668,7 +668,7 @@ char *AddEventBlockToScript(char *script, const char *evtname, const char *scrip postblk[postlen] = 0; sprintf(evtblk, EVT_STATEMENT, evtname); - newtxt = (char *)mem_malloc(strlen(preblk) + strlen(postblk) + strlen(evtblk) + 1); + newtxt = mem_rmalloc(strlen(preblk) + strlen(postblk) + strlen(evtblk) + 1); sprintf(newtxt, "%s%s%s", preblk, evtblk, postblk); delete[] postblk; diff --git a/editor/ObjectDialog.cpp b/editor/ObjectDialog.cpp index 73fc2084..de6024b5 100644 --- a/editor/ObjectDialog.cpp +++ b/editor/ObjectDialog.cpp @@ -1160,7 +1160,7 @@ void CObjectDialog::OnObjectSwapButton() { int o_index = ObjCreate(Object_info[d_id].type, d_id, room, &pos, &orient, parent); if (temp_name[0] != '\0') { - Objects[o_index].name = (char *)mem_malloc(strlen(temp_name) + 1); + Objects[o_index].name = mem_rmalloc(strlen(temp_name) + 1); strcpy(Objects[o_index].name, temp_name); } } diff --git a/editor/Read3ds.cpp b/editor/Read3ds.cpp index 7ddacd59..cf190e03 100644 --- a/editor/Read3ds.cpp +++ b/editor/Read3ds.cpp @@ -371,7 +371,7 @@ skip_combine:; } ASSERT(rp->name == NULL); - rp->name = (char *)mem_malloc(strlen(roomname) + 1); + rp->name = mem_rmalloc(strlen(roomname) + 1); strcpy(rp->name, roomname); // Save it out to disk (locally) diff --git a/editor/ScriptEditorDlg.cpp b/editor/ScriptEditorDlg.cpp index c094b512..d29f4b2a 100644 --- a/editor/ScriptEditorDlg.cpp +++ b/editor/ScriptEditorDlg.cpp @@ -246,7 +246,7 @@ bool CScriptEditorDlg::FindNext(char *w) { // Make a copy of the script to work with char *text; - text = (char *)mem_malloc(GetScriptLength()); + text = mem_rmalloc(GetScriptLength()); strcpy(text, GetScript()); max = GetScriptLength(); diff --git a/editor/ScriptStudio.cpp b/editor/ScriptStudio.cpp index a6348b48..5b8a4e69 100644 --- a/editor/ScriptStudio.cpp +++ b/editor/ScriptStudio.cpp @@ -463,7 +463,7 @@ bool CScriptStudio::FindNext(char *w) { // Make a copy of the script to work with char *text; - text = (char *)mem_malloc(m_EditText.GetLength() + 1); + text = mem_rmalloc(m_EditText.GetLength() + 1); if (!text) Int3(); strcpy(text, (LPCSTR)m_EditText); diff --git a/editor/ScriptWizard.cpp b/editor/ScriptWizard.cpp index 8dcb81ee..545bcca9 100644 --- a/editor/ScriptWizard.cpp +++ b/editor/ScriptWizard.cpp @@ -317,7 +317,7 @@ void CScriptWizard::OnEditScript() { FreeScript(m_ScriptSource); studio.GetText(tempstr); - m_ScriptSource = (char *)mem_malloc(tempstr.GetLength() + 1); + m_ScriptSource = mem_rmalloc(tempstr.GetLength() + 1); if (m_ScriptSource) { strcpy(m_ScriptSource, (LPCSTR)tempstr); diff --git a/editor/TableManage.cpp b/editor/TableManage.cpp index f39e3c28..3e887223 100644 --- a/editor/TableManage.cpp +++ b/editor/TableManage.cpp @@ -393,7 +393,7 @@ void GenericPageList::SaveSelected(CEdit *description) { // Get Copy of new Description text description->GetWindowText(new_descrip); - new_text = (char *)mem_malloc(strlen(new_descrip.GetBuffer(0)) + 1); + new_text = mem_rmalloc(strlen(new_descrip.GetBuffer(0)) + 1); ASSERT(new_text); // out of memory! sprintf(new_text, "%s", new_descrip.GetBuffer(0)); diff --git a/editor/TextureGrWnd.cpp b/editor/TextureGrWnd.cpp index cfc4f476..3100c01b 100644 --- a/editor/TextureGrWnd.cpp +++ b/editor/TextureGrWnd.cpp @@ -1548,7 +1548,7 @@ BOOL CTextureGrWnd::OnCommand(WPARAM wParam, LPARAM lParam) { } if (strlen(tempname)) { - curobj->name = (char *)mem_malloc(strlen(tempname) + 1); + curobj->name = mem_rmalloc(strlen(tempname) + 1); strcpy(curobj->name, tempname); } @@ -1586,14 +1586,14 @@ BOOL CTextureGrWnd::OnCommand(WPARAM wParam, LPARAM lParam) { if (!dlg.m_Module.IsEmpty()) { char module_name[MAX_MODULENAME_LEN]; - curobj->custom_default_module_name = (char *)mem_malloc(dlg.m_Module.GetLength() + 1); + curobj->custom_default_module_name = mem_rmalloc(dlg.m_Module.GetLength() + 1); ddio_SplitPath(dlg.m_Module.GetBuffer(0), NULL, module_name, NULL); strcpy(curobj->custom_default_module_name, module_name); } if (!dlg.m_Name.IsEmpty()) { - curobj->custom_default_script_name = (char *)mem_malloc(dlg.m_Name.GetLength() + 1); + curobj->custom_default_script_name = mem_rmalloc(dlg.m_Name.GetLength() + 1); strcpy(curobj->custom_default_script_name, dlg.m_Name.GetBuffer(0)); } } diff --git a/editor/WorldObjectsDoorDialog.cpp b/editor/WorldObjectsDoorDialog.cpp index bd2330df..72021054 100644 --- a/editor/WorldObjectsDoorDialog.cpp +++ b/editor/WorldObjectsDoorDialog.cpp @@ -634,7 +634,7 @@ void CWorldObjectsDoorDialog::OnDeleteDoor() { // Returns true if got new name, false if cancelled. // the data in buf not changed if cancel is pressed bool InputDoorName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { - char *tempbuf = (char *)mem_malloc(len); + char *tempbuf = mem_rmalloc(len); strcpy(tempbuf, buf); diff --git a/editor/WorldObjectsGenericDialog.cpp b/editor/WorldObjectsGenericDialog.cpp index 037c7c8c..a0af06c1 100644 --- a/editor/WorldObjectsGenericDialog.cpp +++ b/editor/WorldObjectsGenericDialog.cpp @@ -612,7 +612,7 @@ bool InputObjectName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { if (len > (PAGENAME_LEN - 1)) len = PAGENAME_LEN - 1; - char *tempbuf = (char *)mem_malloc(len); + char *tempbuf = mem_rmalloc(len); strncpy(tempbuf, buf, len - 1); tempbuf[len - 1] = '\0'; diff --git a/editor/WorldSoundsDialog.cpp b/editor/WorldSoundsDialog.cpp index 9ab9b56c..b31e830f 100644 --- a/editor/WorldSoundsDialog.cpp +++ b/editor/WorldSoundsDialog.cpp @@ -1102,7 +1102,7 @@ bool InputSoundName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { if (len > (PAGENAME_LEN - 1)) len = PAGENAME_LEN - 1; - char *tempbuf = (char *)mem_malloc(len); + char *tempbuf = mem_rmalloc(len); strncpy(tempbuf, buf, len - 1); tempbuf[len - 1] = '\0'; diff --git a/editor/WorldTexturesDialog.cpp b/editor/WorldTexturesDialog.cpp index a105c0ba..e5873125 100644 --- a/editor/WorldTexturesDialog.cpp +++ b/editor/WorldTexturesDialog.cpp @@ -1998,7 +1998,7 @@ void CWorldTexturesDialog::OnPingPong() { // Returns true if got new name, false if cancelled. // the data in buf not changed if cancel is pressed bool InputTextureName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { - char *tempbuf = (char *)mem_malloc(len); + char *tempbuf = mem_rmalloc(len); strcpy(tempbuf, buf); diff --git a/editor/WorldWeaponsDialog.cpp b/editor/WorldWeaponsDialog.cpp index 9b623187..70333d88 100644 --- a/editor/WorldWeaponsDialog.cpp +++ b/editor/WorldWeaponsDialog.cpp @@ -1579,7 +1579,7 @@ void CWorldWeaponsDialog::OnEditPhysics() { // Returns true if got new name, false if cancelled. // the data in buf not changed if cancel is pressed bool InputWeaponName(char *buf, int len, char *title, char *prompt, CWnd *wnd) { - char *tempbuf = (char *)mem_malloc(len); + char *tempbuf = mem_rmalloc(len); strcpy(tempbuf, buf); diff --git a/editor/editorView.cpp b/editor/editorView.cpp index 3f08a44b..ef7b253d 100644 --- a/editor/editorView.cpp +++ b/editor/editorView.cpp @@ -1269,7 +1269,7 @@ try_again:; } if (strlen(tempname)) { - Curroomp->name = (char *)mem_malloc(strlen(tempname) + 1); + Curroomp->name = mem_rmalloc(strlen(tempname) + 1); strcpy(Curroomp->name, tempname); } diff --git a/editor/roomkeypaddialog.cpp b/editor/roomkeypaddialog.cpp index 5acbc7de..7bbda764 100644 --- a/editor/roomkeypaddialog.cpp +++ b/editor/roomkeypaddialog.cpp @@ -437,7 +437,7 @@ void CRoomKeypadDialog::OnLoadRoom() { } ASSERT(Rooms[n].name == NULL); - Rooms[n].name = (char *)mem_malloc(strlen(roomname) + 1); + Rooms[n].name = mem_rmalloc(strlen(roomname) + 1); strcpy(Rooms[n].name, roomname); D3EditState.current_room = n; diff --git a/grtext/grtext.cpp b/grtext/grtext.cpp index acb49c25..c17af497 100644 --- a/grtext/grtext.cpp +++ b/grtext/grtext.cpp @@ -461,7 +461,7 @@ void grtext_Puts(int x, int y, const char *str) { if (grtext_FilterProfanity) { // DAJ changed to local to reduce memory thrashing - // DAJ char *lowerstr = (char *)mem_malloc(strlen(str)+1); + // DAJ char *lowerstr = mem_rmalloc(strlen(str)+1); char lowerstr[GR_STR_LEN]; int slen = strlen(str); diff --git a/manage/generic.cpp b/manage/generic.cpp index bd10e3c8..afed50c5 100644 --- a/manage/generic.cpp +++ b/manage/generic.cpp @@ -1144,7 +1144,7 @@ int mng_ReadNewGenericPage(CFILE *infile, mngs_generic_page *genericpage) { cf_ReadString(tempbuf, 1024, infile); size_t slen = strlen(tempbuf) + 1; - genericpage->objinfo_struct.description = (char *)mem_malloc(slen); + genericpage->objinfo_struct.description = mem_rmalloc(slen); ASSERT(genericpage->objinfo_struct.description); strcpy(genericpage->objinfo_struct.description, tempbuf); } else diff --git a/music/sequencer.cpp b/music/sequencer.cpp index df0c33cc..6a2130aa 100644 --- a/music/sequencer.cpp +++ b/music/sequencer.cpp @@ -179,7 +179,7 @@ bool OutrageMusicSeq::Init(const char *theme_file) { // initialize memory buffers m_ins_buffer = mem_rmalloc(MAX_MUSIC_INSTRUCTIONS); - m_str_buffer = (char *)mem_malloc(MAX_MUSIC_STRLEN); + m_str_buffer = mem_rmalloc(MAX_MUSIC_STRLEN); m_ins_curptr = m_ins_buffer; m_str_curptr = m_str_buffer; m_str_curptr[0] = 0; diff --git a/ui/UIConsole.cpp b/ui/UIConsole.cpp index 8d7c79d0..764cc548 100644 --- a/ui/UIConsole.cpp +++ b/ui/UIConsole.cpp @@ -110,7 +110,7 @@ void UIConsoleGadget::Create(UIWindow *parent, int id, int x, int y, int font, i // extra 32 bytes per row for color coding. m_ConsoleBuffer = (char *)mem_malloc(m_Rows * m_Rowsize); m_PutsBufLen = 512; - m_PutsBuffer = (char *)mem_malloc(m_PutsBufLen); + m_PutsBuffer = mem_rmalloc(m_PutsBufLen); m_ColorRows = new ddgr_color[m_Rows]; memset(m_ConsoleBuffer, 0, m_Rows * m_Rowsize); @@ -141,7 +141,7 @@ void UIConsoleGadget::puts(ddgr_color col, const char *str) { if (len >= m_PutsBufLen) { mem_free(m_PutsBuffer); m_PutsBufLen = len + 1; - m_PutsBuffer = (char *)mem_malloc(m_PutsBufLen); + m_PutsBuffer = mem_rmalloc(m_PutsBufLen); } textaux_WordWrap(str, m_PutsBuffer, m_W - 2 * m_OffX, m_ConsoleFont);