From 3c9234c4c083ef2e7996caa5eb49e224dd525b50 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Sun, 8 Sep 2024 13:29:41 +0200 Subject: [PATCH] mem_malloc type triviality checks (8/8) (Manual modification.) Change mem_malloc callsites with non-fundamental types to mem_rmalloc. --- Descent3/ambient.cpp | 2 +- Descent3/demofile.cpp | 2 +- Descent3/doorway.cpp | 2 +- Descent3/loadstate.cpp | 13 ++++--------- Descent3/newui_core.cpp | 2 +- Descent3/object_lighting.cpp | 2 +- Descent3/pilot_class.cpp | 2 +- Descent3/room.cpp | 4 ++-- Descent3/terrain.cpp | 4 ++-- cfile/cfile.cpp | 6 +++--- editor/AmbientSoundPattern.cpp | 4 ++-- editor/Erooms.cpp | 18 ++++++++---------- editor/Group.cpp | 18 ++++++++---------- editor/editor_lighting.cpp | 18 +++++++++--------- editor/editor_object_lighting.cpp | 8 ++++---- manage/manage.cpp | 2 +- manage/texpage.cpp | 2 +- model/polymodel.cpp | 6 +++--- 18 files changed, 53 insertions(+), 62 deletions(-) diff --git a/Descent3/ambient.cpp b/Descent3/ambient.cpp index ca928289..ade9f295 100644 --- a/Descent3/ambient.cpp +++ b/Descent3/ambient.cpp @@ -256,7 +256,7 @@ void ReadAmbientData() { asp->num_sounds = cf_ReadInt(ifile); if (asp->num_sounds > 0) - asp->sounds = (ase *)mem_malloc(sizeof(*asp->sounds) * asp->num_sounds); + asp->sounds = mem_rmalloc(asp->num_sounds); else asp->sounds = NULL; diff --git a/Descent3/demofile.cpp b/Descent3/demofile.cpp index 2024500e..2942c208 100644 --- a/Descent3/demofile.cpp +++ b/Descent3/demofile.cpp @@ -785,7 +785,7 @@ int DemoReadHeader() { if (gs_Xlates) mem_free(gs_Xlates); - gs_Xlates = (struct gs_tables *)mem_malloc(sizeof(gs_tables)); + gs_Xlates = mem_rmalloc(); try { LGSXlateTables(Demo_cfp); diff --git a/Descent3/doorway.cpp b/Descent3/doorway.cpp index f970a35a..f074b687 100644 --- a/Descent3/doorway.cpp +++ b/Descent3/doorway.cpp @@ -646,7 +646,7 @@ doorway *DoorwayAdd(room *rp, int doornum) { rp->flags |= RF_DOOR; - doorway *dp = rp->doorway_data = (doorway *)mem_malloc(sizeof(*rp->doorway_data)); + auto dp = rp->doorway_data = mem_rmalloc(); // Initialize dp->doornum = doornum; diff --git a/Descent3/loadstate.cpp b/Descent3/loadstate.cpp index 816926af..5fe61a39 100644 --- a/Descent3/loadstate.cpp +++ b/Descent3/loadstate.cpp @@ -838,7 +838,7 @@ int LGSObjects(CFILE *fp, int version) { int i, j, highest_index; int max_terr; - matrix *objmat = (matrix *)mem_malloc(sizeof(*objmat) * MAX_OBJECTS); + auto objmat = mem_rmalloc(MAX_OBJECTS); Osiris_DisableCreateEvents(); // we must reset some data before continuing. @@ -992,7 +992,7 @@ int LGSObjects(CFILE *fp, int version) { gs_ReadByte(fp, has_lightinfo); if (has_lightinfo) { if (!op->lighting_info) { - op->lighting_info = (light_info *)mem_malloc(sizeof(*op->lighting_info)); + op->lighting_info = mem_rmalloc(); } cf_ReadBytes((uint8_t *)op->lighting_info, sizeof(*op->lighting_info), fp); } @@ -1443,7 +1443,6 @@ done:; // loads ai int LGSObjAI(CFILE *fp, ai_frame **pai) { - ai_frame *ai; int16_t size; int8_t read_ai; @@ -1457,9 +1456,7 @@ int LGSObjAI(CFILE *fp, ai_frame **pai) { if (size != sizeof(ai_frame)) return LGS_OUTDATEDVER; - *pai = (ai_frame *)mem_malloc(size); - ai = *pai; - + auto ai = *pai = mem_rmalloc(); cf_ReadBytes((uint8_t *)ai, size, fp); return LGS_OK; @@ -1478,9 +1475,7 @@ int LGSObjEffects(CFILE *fp, object *op) { if (size != sizeof(effect_info_s)) return LGS_OUTDATEDVER; - op->effect_info = (effect_info_s *)mem_malloc(size); - effect_info_s *ei = op->effect_info; - + auto ei = op->effect_info = mem_rmalloc(); cf_ReadBytes((uint8_t *)ei, size, fp); } diff --git a/Descent3/newui_core.cpp b/Descent3/newui_core.cpp index 09eb1fab..7346455c 100644 --- a/Descent3/newui_core.cpp +++ b/Descent3/newui_core.cpp @@ -1203,7 +1203,7 @@ void newuiSheet::Create(UIWindow *menu, const char *title, int n_items, int sx, m_gadgetlimit = n_items; m_ngadgets = 0; if (n_items) { - m_gadgetlist = (newuiSheet::t_gadget_desc *)mem_malloc(n_items * sizeof(newuiSheet::t_gadget_desc)); + m_gadgetlist = mem_rmalloc(n_items); } else { m_gadgetlist = NULL; } diff --git a/Descent3/object_lighting.cpp b/Descent3/object_lighting.cpp index 8b808483..5b2caec7 100644 --- a/Descent3/object_lighting.cpp +++ b/Descent3/object_lighting.cpp @@ -630,7 +630,7 @@ void ObjSetLocalLighting(object *objp) { (objp->type == OBJ_BUILDING)); // allocate a light info for this object - objp->lighting_info = (light_info *)mem_malloc(sizeof(*objp->lighting_info)); + objp->lighting_info = mem_rmalloc(); // copy the lighting info from the type for this object *objp->lighting_info = Object_info[objp->id].lighting_info; diff --git a/Descent3/pilot_class.cpp b/Descent3/pilot_class.cpp index 7bfb8579..ad33cdfb 100644 --- a/Descent3/pilot_class.cpp +++ b/Descent3/pilot_class.cpp @@ -899,7 +899,7 @@ void pilot::add_mission_data(tMissionData *mdata) { LOG_DEBUG.printf("Adding new mission data for (%s)", mdata->mission_name); - tMissionData *new_data = (tMissionData *)mem_malloc((num_missions_flown + 1) * sizeof(tMissionData)); + auto new_data = mem_rmalloc(num_missions_flown + 1); if (!new_data) { LOG_WARNING << "Out of memory"; return; diff --git a/Descent3/room.cpp b/Descent3/room.cpp index 43b06367..2c34864b 100644 --- a/Descent3/room.cpp +++ b/Descent3/room.cpp @@ -567,7 +567,7 @@ void InitRoom(room *rp, int nverts, int nfaces, int nportals) { ASSERT(rp->verts != NULL); if (Katmai) { - rp->verts4 = (vector4 *)mem_malloc(nverts * sizeof(*rp->verts4)); + rp->verts4 = mem_rmalloc(nverts); ASSERT(rp->verts4 != NULL); } @@ -667,7 +667,7 @@ void FreeRoom(room *rp) { RoomMemFree(rp->portals); RoomMemFree(rp->verts); - if (Katmai) + if (Katmai ) mem_free(rp->verts4); if (rp->num_bbf_regions) { diff --git a/Descent3/terrain.cpp b/Descent3/terrain.cpp index a8aaf527..67772c84 100644 --- a/Descent3/terrain.cpp +++ b/Descent3/terrain.cpp @@ -957,7 +957,7 @@ void InitTerrain(void) { Terrain_rotate_list = (uint16_t *)mem_malloc(TERRAIN_WIDTH * TERRAIN_DEPTH * sizeof(uint16_t)); ASSERT(Terrain_rotate_list); - World_point_buffer = (g3Point *)mem_malloc(TERRAIN_WIDTH * TERRAIN_DEPTH * sizeof(g3Point)); + World_point_buffer = mem_rmalloc(TERRAIN_WIDTH * TERRAIN_DEPTH); ASSERT(World_point_buffer); // Allocate space for lod delta tree and unique texture IDs @@ -975,7 +975,7 @@ void InitTerrain(void) { w = TERRAIN_WIDTH >> ((MAX_TERRAIN_LOD - 1) - i); h = TERRAIN_DEPTH >> ((MAX_TERRAIN_LOD - 1) - i); - TerrainNormals[i] = (terrain_normals *)mem_malloc(w * h * sizeof(terrain_normals)); + TerrainNormals[i] = mem_rmalloc(w * h); memset(TerrainNormals[i], 0, w * h * sizeof(terrain_normals)); } diff --git a/cfile/cfile.cpp b/cfile/cfile.cpp index 1bd62135..efe6001c 100644 --- a/cfile/cfile.cpp +++ b/cfile/cfile.cpp @@ -282,7 +282,7 @@ CFILE *cf_OpenFileInLibrary(const std::filesystem::path &filename, int libhandle return nullptr; } } - CFILE *cfile = (CFILE *)mem_malloc(sizeof(*cfile)); + auto cfile = mem_rmalloc(); if (!cfile) Error("Out of memory in cf_OpenFileInLibrary()"); cfile->name = lib->entries[i]->name; @@ -335,7 +335,7 @@ CFILE *open_file_in_lib(const char *filename) { return nullptr; } } - cfile = (CFILE *)mem_malloc(sizeof(*cfile)); + cfile = mem_rmalloc(); if (!cfile) Error("Out of memory in open_file_in_lib()"); cfile->name = lib->entries[i]->name; @@ -451,7 +451,7 @@ CFILE *open_file_in_directory(const std::filesystem::path &filename, const char } // found the file, open it - cfile = (CFILE *)mem_malloc(sizeof(*cfile)); + cfile = mem_rmalloc(); if (!cfile) Error("Out of memory in open_file_in_directory()"); cfile->name = mem_rmalloc((strlen(using_filename.u8string().c_str()) + 1)); diff --git a/editor/AmbientSoundPattern.cpp b/editor/AmbientSoundPattern.cpp index 74b13e25..622d615d 100644 --- a/editor/AmbientSoundPattern.cpp +++ b/editor/AmbientSoundPattern.cpp @@ -217,7 +217,7 @@ void CAmbientSoundPattern::OnASPNewElement() { if (new_element.handle != -1) { - ase *new_sounds = (ase *)mem_malloc(sizeof(*new_sounds) * (asp->num_sounds + 1)); + auto new_sounds = mem_rmalloc(asp->num_sounds + 1); for (int s = 0; s < asp->num_sounds; s++) new_sounds[s] = asp->sounds[s]; @@ -252,7 +252,7 @@ void CAmbientSoundPattern::OnASPDeleteElement() { if (m_current_element > -1) { if (OutrageMessageBox(MBOX_YESNO, "Do you really want to delete sound '%s' from pattern '%s'?", Sounds[asp->sounds[m_current_element].handle].name, asp->name) == IDYES) { - new_sounds = (ase *)mem_malloc(sizeof(*new_sounds) * (asp->num_sounds - 1)); + new_sounds = mem_rmalloc(asp->num_sounds - 1); for (int s = 0; s < m_current_element; s++) new_sounds[s] = asp->sounds[s]; diff --git a/editor/Erooms.cpp b/editor/Erooms.cpp index 8fe8f980..03c33037 100644 --- a/editor/Erooms.cpp +++ b/editor/Erooms.cpp @@ -1343,7 +1343,7 @@ void ReInitRoomFace(face *fp, int nverts) { fp->face_verts = (int16_t *)mem_malloc(nverts * sizeof(*fp->face_verts)); ASSERT(fp->face_verts != NULL); - fp->face_uvls = (roomUVL *)mem_malloc(nverts * sizeof(*fp->face_uvls)); + fp->face_uvls = mem_rmalloc(nverts); ASSERT(fp->face_uvls != NULL); } @@ -1395,7 +1395,7 @@ int RoomAddVertices(room *rp, int num_new_verts) { if (num_new_verts == 0) return 0; - vector *newverts = (vector *)mem_malloc((rp->num_verts + num_new_verts) * sizeof(*newverts)); + auto newverts = mem_rmalloc(rp->num_verts + num_new_verts); ASSERT(newverts != NULL); @@ -1422,7 +1422,7 @@ int RoomAddFaces(room *rp, int num_new_faces) { if (num_new_faces == 0) return 0; - face *newfaces = (face *)mem_malloc((rp->num_faces + num_new_faces) * sizeof(*newfaces)); + auto newfaces = mem_rmalloc(rp->num_faces + num_new_faces); ASSERT(newfaces != NULL); @@ -1635,7 +1635,7 @@ void DeleteRoomVert(room *rp, int vertnum) { fp->face_verts[v]--; // malloc new list - newverts = (vector *)mem_malloc(sizeof(*newverts) * (rp->num_verts - 1)); + newverts = mem_rmalloc(rp->num_verts - 1); ASSERT(newverts != NULL); // Copy verts to new list @@ -1717,7 +1717,7 @@ void DeleteRoomFace(room *rp, int facenum, bool delete_unused_verts) { } // Allocate new face list - newfaces = (face *)mem_malloc(sizeof(*newfaces) * (rp->num_faces - 1)); + newfaces = mem_rmalloc(rp->num_faces - 1); ASSERT(newfaces != NULL); // Copy faces over @@ -1810,7 +1810,7 @@ void DeleteRoomPortal(room *rp, int portalnum) { if (rp->num_portals == 1) newportals = NULL; else { - newportals = (portal *)mem_malloc(sizeof(*newportals) * (rp->num_portals - 1)); + newportals = mem_rmalloc(rp->num_portals - 1); ASSERT(newportals != NULL); } @@ -1956,7 +1956,7 @@ void CopyRoom(room *destp, room *srcp) { // Copy doorway info if (srcp->doorway_data) { - destp->doorway_data = (doorway *)mem_malloc(sizeof(*destp->doorway_data)); + destp->doorway_data = mem_rmalloc(); *destp->doorway_data = *srcp->doorway_data; } @@ -1973,9 +1973,7 @@ void CopyRoom(room *destp, room *srcp) { // Adds a new portal for this room. Returns the portal number. // Initializes the flags int AddPortal(room *rp) { - portal *newlist; - - newlist = (portal *)mem_malloc(sizeof(*newlist) * (rp->num_portals + 1)); + auto newlist = mem_rmalloc(rp->num_portals + 1); // Copy from old list to new list, and free old list if (rp->num_portals) { diff --git a/editor/Group.cpp b/editor/Group.cpp index ccc24236..2a4c7c6f 100644 --- a/editor/Group.cpp +++ b/editor/Group.cpp @@ -236,16 +236,15 @@ void FreeGroup(group *g) { // attachroom, attachface - where group attaches when pasted // Returns: pointer to group group *CopyGroup(int nrooms, int *roomnums, int attachroom, int attachface) { - group *g; int r; int room_xlate[MAX_ROOMS]; int n_objects = 0, n_triggers = 0, n_doors = 0; // Allocate group & room arrays - g = (group *)mem_malloc(sizeof(*g)); + auto g = mem_rmalloc(); ASSERT(g != NULL); g->nrooms = nrooms; - g->rooms = (room *)mem_malloc(sizeof(*g->rooms) * nrooms); + g->rooms = mem_rmalloc(nrooms); ASSERT(g->rooms != NULL); // Initialize xlate list @@ -296,7 +295,7 @@ group *CopyGroup(int nrooms, int *roomnums, int attachroom, int attachface) { int objnum = 0; // Get memory for objects - g->objects = (object *)mem_malloc(sizeof(*g->objects) * n_objects); + g->objects = mem_rmalloc(n_objects); // Go through list of rooms & copy the objects for (r = 0; r < nrooms; r++) { @@ -344,7 +343,7 @@ group *CopyGroup(int nrooms, int *roomnums, int attachroom, int attachface) { int trignum = 0; // Get memory for triggers - g->triggers = (trigger *)mem_malloc(sizeof(*g->triggers) * n_triggers); + g->triggers = mem_rmalloc(n_triggers); for (int t = 0; t < Num_triggers; t++) if (room_xlate[Triggers[t].roomnum] != -1) { @@ -754,7 +753,6 @@ group *LoadGroup(char *filename) { CFILE *ifile; char tag[4]; int version, level_version; - group *g; int i; ifile = cfopen(filename, "rb"); @@ -794,7 +792,7 @@ group *LoadGroup(char *filename) { ReadTextureList(ifile); // Allocate group - g = (group *)mem_malloc(sizeof(*g)); + auto g = mem_rmalloc(); // Read group info g->nrooms = cf_ReadInt(ifile); @@ -810,7 +808,7 @@ group *LoadGroup(char *filename) { g->nobjects = g->ndoors = g->ntriggers = 0; // Allocate room and vertex arrays - g->rooms = (room *)mem_malloc(sizeof(*g->rooms) * g->nrooms); + g->rooms = mem_rmalloc(g->nrooms); // Read rooms for (i = 0; i < g->nrooms; i++) { @@ -825,11 +823,11 @@ group *LoadGroup(char *filename) { // Allocate objects array if (g->nobjects) - g->objects = (object *)mem_malloc(sizeof(*g->objects) * g->nobjects); + g->objects = mem_rmalloc(g->nobjects); // Allocate triggers array if (g->ntriggers) - g->triggers = (trigger *)mem_malloc(sizeof(*g->triggers) * g->ntriggers); + g->triggers = mem_rmalloc(g->ntriggers); // Read objects for (i = 0; i < g->nobjects; i++) diff --git a/editor/editor_lighting.cpp b/editor/editor_lighting.cpp index ba2cd222..205cab82 100644 --- a/editor/editor_lighting.cpp +++ b/editor/editor_lighting.cpp @@ -903,7 +903,7 @@ void DoRadiosityForRooms() { Rooms[roomnum].volume_lights = (uint8_t *)mem_malloc(vw * vh * vd); ASSERT(Rooms[roomnum].volume_lights); - Volume_elements[roomnum] = (volume_element *)mem_malloc((vw * vh * vd) * sizeof(volume_element)); + Volume_elements[roomnum] = mem_rmalloc(vw * vh * vd); ASSERT(Volume_elements[roomnum]); // Now go through and find all the valid spectra points @@ -977,8 +977,8 @@ void DoRadiosityForRooms() { if (Light_surfaces[surface_index].xresolution * Light_surfaces[surface_index].yresolution) { Light_surfaces[surface_index].elements = - (rad_element *)mem_malloc(Light_surfaces[surface_index].xresolution * - Light_surfaces[surface_index].yresolution * sizeof(rad_element)); + mem_rmalloc(Light_surfaces[surface_index].xresolution * + Light_surfaces[surface_index].yresolution); ASSERT(Light_surfaces[surface_index].elements != NULL); } else { Light_surfaces[surface_index].elements = NULL; @@ -1223,8 +1223,8 @@ void DoRadiosityForCurrentRoom(room *rp) { } if (Light_surfaces[surface_index].xresolution * Light_surfaces[surface_index].yresolution) { - Light_surfaces[surface_index].elements = (rad_element *)mem_malloc( - Light_surfaces[surface_index].xresolution * Light_surfaces[surface_index].yresolution * sizeof(rad_element)); + Light_surfaces[surface_index].elements = mem_rmalloc( + Light_surfaces[surface_index].xresolution * Light_surfaces[surface_index].yresolution); ASSERT(Light_surfaces[surface_index].elements != NULL); } else { Light_surfaces[surface_index].elements = NULL; @@ -1873,8 +1873,8 @@ void DoRadiosityForTerrain() { ClearAllObjectLightmaps(1); // Allocate memory - terrain_sums[0] = (spectra *)mem_malloc(TERRAIN_WIDTH * TERRAIN_DEPTH * sizeof(spectra)); - terrain_sums[1] = (spectra *)mem_malloc(TERRAIN_WIDTH * TERRAIN_DEPTH * sizeof(spectra)); + terrain_sums[0] = mem_rmalloc(TERRAIN_WIDTH * TERRAIN_DEPTH); + terrain_sums[1] = mem_rmalloc(TERRAIN_WIDTH * TERRAIN_DEPTH); ASSERT(terrain_sums[0] && terrain_sums[1]); Light_surfaces = mem_rmalloc(total_surfaces); @@ -2044,8 +2044,8 @@ void DoRadiosityForTerrain() { Light_surfaces[surf_index].verts = mem_rmalloc(Rooms[i].faces[t].num_verts); ASSERT(Light_surfaces[surf_index].verts != NULL); - Light_surfaces[surf_index].elements = (rad_element *)mem_malloc( - Light_surfaces[surf_index].xresolution * Light_surfaces[surf_index].yresolution * sizeof(rad_element)); + Light_surfaces[surf_index].elements = mem_rmalloc( + Light_surfaces[surf_index].xresolution * Light_surfaces[surf_index].yresolution); ASSERT(Light_surfaces[surf_index].elements != NULL); if (Rooms[i].faces[t].portal_num != -1 && diff --git a/editor/editor_object_lighting.cpp b/editor/editor_object_lighting.cpp index a91e5c8e..f26dddf9 100644 --- a/editor/editor_object_lighting.cpp +++ b/editor/editor_object_lighting.cpp @@ -321,8 +321,8 @@ int ComputeSurfacesForObjects(int surface_index, int terrain) { if (Light_surfaces[surface_index].xresolution * Light_surfaces[surface_index].yresolution > 0) { Light_surfaces[surface_index].elements = - (rad_element *)mem_malloc(Light_surfaces[surface_index].xresolution * - Light_surfaces[surface_index].yresolution * sizeof(rad_element)); + mem_rmalloc(Light_surfaces[surface_index].xresolution * + Light_surfaces[surface_index].yresolution); ASSERT(Light_surfaces[surface_index].elements != NULL); } else Light_surfaces[surface_index].elements = NULL; @@ -407,8 +407,8 @@ int ComputeSurfacesForObjectsForSingleRoom(int surface_index, int roomnum) { if (Light_surfaces[surface_index].xresolution * Light_surfaces[surface_index].yresolution > 0) { Light_surfaces[surface_index].elements = - (rad_element *)mem_malloc(Light_surfaces[surface_index].xresolution * - Light_surfaces[surface_index].yresolution * sizeof(rad_element)); + mem_rmalloc(Light_surfaces[surface_index].xresolution * + Light_surfaces[surface_index].yresolution); ASSERT(Light_surfaces[surface_index].elements != NULL); } else Light_surfaces[surface_index].elements = NULL; diff --git a/manage/manage.cpp b/manage/manage.cpp index 5dd000f2..ff2f6050 100644 --- a/manage/manage.cpp +++ b/manage/manage.cpp @@ -1466,7 +1466,7 @@ void mng_TransferPages() { Int3(); return; } - mngs_track_lock *local_tracklocks = (mngs_track_lock *)mem_malloc(sizeof(*local_tracklocks) * 5000); + auto local_tracklocks = mem_rmalloc(5000); // Do textures int done = 0; while (!done) { diff --git a/manage/texpage.cpp b/manage/texpage.cpp index 82aded88..53b4ae3c 100644 --- a/manage/texpage.cpp +++ b/manage/texpage.cpp @@ -1247,7 +1247,7 @@ int mng_GetGuaranteedTexturePage(char *name, CFILE *infile) { if (i != -1) return i; - mngs_texture_page *texpage = (mngs_texture_page *)mem_malloc(sizeof(*texpage)); + auto texpage = mem_rmalloc(); // Not in memory. Load it from the table file. Start searching from the // current spot in the open table file diff --git a/model/polymodel.cpp b/model/polymodel.cpp index 9a56642a..1bec6b1b 100644 --- a/model/polymodel.cpp +++ b/model/polymodel.cpp @@ -1802,9 +1802,9 @@ int ReadNewModelFile(int polynum, CFILE *infile) { pm->submodel[i].num_key_angles = nframes; } - pm->submodel[i].keyframe_axis = (vector *)mem_malloc((pm->submodel[i].num_key_angles + 1) * sizeof(vector)); + pm->submodel[i].keyframe_axis = mem_rmalloc(pm->submodel[i].num_key_angles + 1); pm->submodel[i].keyframe_angles = (int *)mem_malloc((pm->submodel[i].num_key_angles + 1) * sizeof(int)); - pm->submodel[i].keyframe_matrix = (matrix *)mem_malloc((pm->submodel[i].num_key_angles + 1) * sizeof(matrix)); + pm->submodel[i].keyframe_matrix = mem_rmalloc(pm->submodel[i].num_key_angles + 1); if (timed) { pm->submodel[i].rot_start_time = (int *)mem_malloc((pm->submodel[i].num_key_angles + 1) * sizeof(int)); ASSERT(pm->submodel[i].rot_start_time != nullptr); @@ -1892,7 +1892,7 @@ int ReadNewModelFile(int polynum, CFILE *infile) { } else pm->submodel[i].num_key_pos = nframes; - pm->submodel[i].keyframe_pos = (vector *)mem_malloc((pm->submodel[i].num_key_pos + 1) * sizeof(vector)); + pm->submodel[i].keyframe_pos = mem_rmalloc(pm->submodel[i].num_key_pos + 1); ASSERT(pm->submodel[i].keyframe_pos != nullptr); if (timed) {