mirror of
https://github.com/kevinbentley/Descent3.git
synced 2025-01-22 11:28:56 +00:00
mem_malloc type triviality checks (4/8)
``` git grep -l mem_malloc | xargs perl -i -lpe 's{\((\w+) \*\)mem_malloc\((\S+) \* sizeof\(\1\)\)}{mem_rmalloc<$1 *>($2)}' ```
This commit is contained in:
parent
bb38a4a565
commit
4d2fdb2316
@ -2147,7 +2147,7 @@ void ComputeAABB(bool f_full) {
|
||||
if (BOA_AABB_ROOM_checksum[i] != 0 && BOA_AABB_ROOM_checksum[i] == computed_room_check[i])
|
||||
continue;
|
||||
|
||||
r_struct_list[i] = (int16_t *)mem_malloc(Rooms[i].num_faces * sizeof(int16_t));
|
||||
r_struct_list[i] = mem_rmalloc<int16_t>(Rooms[i].num_faces);
|
||||
}
|
||||
}
|
||||
|
||||
@ -2318,8 +2318,8 @@ void ComputeAABB(bool f_full) {
|
||||
//
|
||||
// continue;
|
||||
|
||||
vector *s_max_xyz = (vector *)mem_malloc(num_structs_per_room[i] * sizeof(vector));
|
||||
vector *s_min_xyz = (vector *)mem_malloc(num_structs_per_room[i] * sizeof(vector));
|
||||
vector *s_max_xyz = mem_rmalloc<vector>(num_structs_per_room[i]);
|
||||
vector *s_min_xyz = mem_rmalloc<vector>(num_structs_per_room[i]);
|
||||
|
||||
for (count = 0; count < num_structs_per_room[i]; count++) {
|
||||
|
||||
@ -2412,12 +2412,12 @@ void ComputeAABB(bool f_full) {
|
||||
rp->num_bbf_regions = 27 + num_structs_per_room[i] - 1;
|
||||
rp->bbf_list = (int16_t **)mem_malloc(MAX_REGIONS_PER_ROOM * sizeof(int16_t *));
|
||||
for (x = 0; x < MAX_REGIONS_PER_ROOM; x++) {
|
||||
rp->bbf_list[x] = (int16_t *)mem_malloc(rp->num_faces * sizeof(int16_t));
|
||||
rp->bbf_list[x] = mem_rmalloc<int16_t>(rp->num_faces);
|
||||
}
|
||||
rp->num_bbf = (int16_t *)mem_malloc(MAX_REGIONS_PER_ROOM * sizeof(int16_t));
|
||||
rp->bbf_list_min_xyz = (vector *)mem_malloc(MAX_REGIONS_PER_ROOM * sizeof(vector));
|
||||
rp->bbf_list_max_xyz = (vector *)mem_malloc(MAX_REGIONS_PER_ROOM * sizeof(vector));
|
||||
rp->bbf_list_sector = (uint8_t *)mem_malloc(MAX_REGIONS_PER_ROOM * sizeof(uint8_t));
|
||||
rp->num_bbf = mem_rmalloc<int16_t>(MAX_REGIONS_PER_ROOM);
|
||||
rp->bbf_list_min_xyz = mem_rmalloc<vector>(MAX_REGIONS_PER_ROOM);
|
||||
rp->bbf_list_max_xyz = mem_rmalloc<vector>(MAX_REGIONS_PER_ROOM);
|
||||
rp->bbf_list_sector = mem_rmalloc<uint8_t>(MAX_REGIONS_PER_ROOM);
|
||||
|
||||
for (x = 0; x < 27; x++) {
|
||||
rp->bbf_list_sector[x] = bbf_lookup[x];
|
||||
|
@ -2661,7 +2661,7 @@ void ReadNewLightmapChunk(CFILE *fp, int version) {
|
||||
return;
|
||||
}
|
||||
|
||||
uint16_t *lightmap_remap = (uint16_t *)mem_malloc(MAX_LIGHTMAPS * sizeof(uint16_t));
|
||||
uint16_t *lightmap_remap = mem_rmalloc<uint16_t>(MAX_LIGHTMAPS);
|
||||
|
||||
nummaps = cf_ReadInt(fp);
|
||||
|
||||
@ -2897,7 +2897,7 @@ void ReadGamePathsChunk(CFILE *fp, int version) {
|
||||
for (i = 0; i < Num_game_paths; i++) {
|
||||
GamePaths[i].used = 1;
|
||||
GamePaths[i].name[0] = 0;
|
||||
GamePaths[i].pathnodes = (node *)mem_malloc(MAX_NODES_PER_PATH * sizeof(node));
|
||||
GamePaths[i].pathnodes = mem_rmalloc<node>(MAX_NODES_PER_PATH);
|
||||
GamePaths[i].flags = 0;
|
||||
|
||||
// Read in the path's info
|
||||
@ -4884,7 +4884,7 @@ void WriteLightmapChunk(CFILE *fp) {
|
||||
int lightmap_info_count = 0;
|
||||
int lightmap_count = 0;
|
||||
|
||||
uint16_t *lightmap_remap = (uint16_t *)mem_malloc(MAX_LIGHTMAPS * sizeof(uint16_t));
|
||||
uint16_t *lightmap_remap = mem_rmalloc<uint16_t>(MAX_LIGHTMAPS);
|
||||
uint8_t *lightmap_spoken_for = (uint8_t *)mem_malloc(MAX_LIGHTMAPS);
|
||||
|
||||
ASSERT(lightmap_remap);
|
||||
|
@ -756,7 +756,7 @@ char taunt_LoadWaveFile(const char *filename, tWaveFile *wave) {
|
||||
if (wave->sample_16bit == NULL) {
|
||||
ASSERT(wave->sample_8bit);
|
||||
|
||||
wave->sample_16bit = (int16_t *)mem_malloc(wave->sample_length * sizeof(int16_t));
|
||||
wave->sample_16bit = mem_rmalloc<int16_t>(wave->sample_length);
|
||||
|
||||
// NOTE: Interesting note on sound conversion: 16 bit sounds are signed (0 biase). 8 bit sounds are unsigned
|
||||
// (+128 biase).
|
||||
|
@ -56,9 +56,9 @@ void InitLightmapInfo(int nummaps) {
|
||||
return;
|
||||
|
||||
if (nummaps == 0) {
|
||||
LightmapInfo = (lightmap_info *)mem_malloc(MAX_LIGHTMAP_INFOS * sizeof(lightmap_info));
|
||||
LightmapInfo = mem_rmalloc<lightmap_info>(MAX_LIGHTMAP_INFOS);
|
||||
ASSERT(LightmapInfo);
|
||||
Free_lmi_list = (uint16_t *)mem_malloc(MAX_LIGHTMAP_INFOS * sizeof(uint16_t));
|
||||
Free_lmi_list = mem_rmalloc<uint16_t>(MAX_LIGHTMAP_INFOS);
|
||||
ASSERT(Free_lmi_list);
|
||||
|
||||
for (i = 0; i < MAX_LIGHTMAP_INFOS; i++) {
|
||||
|
@ -540,7 +540,7 @@ void SetupObjectLightmapMemory(object *obj) {
|
||||
|
||||
obj->lm_object.num_faces[Mnum] = pm->submodel[Mnum].num_faces;
|
||||
obj->lm_object.lightmap_faces[Mnum] =
|
||||
(lightmap_object_face *)mem_malloc(obj->lm_object.num_faces[Mnum] * sizeof(lightmap_object_face));
|
||||
mem_rmalloc<lightmap_object_face>(obj->lm_object.num_faces[Mnum]);
|
||||
ASSERT(obj->lm_object.lightmap_faces[Mnum]);
|
||||
|
||||
for (Fnum = 0; Fnum < pm->submodel[Mnum].num_faces; Fnum++) {
|
||||
|
@ -3165,7 +3165,7 @@ void ShowPilotPicDialog(pilot *Pilot) {
|
||||
// Initialize PPicDlgInfo data
|
||||
// ---------------------------
|
||||
uint16_t *id_list;
|
||||
id_list = (uint16_t *)mem_malloc(num_pilots * sizeof(uint16_t));
|
||||
id_list = mem_rmalloc<uint16_t>(num_pilots);
|
||||
|
||||
if (!id_list) {
|
||||
// out of memory
|
||||
|
@ -3658,7 +3658,7 @@ void ConsolidateMineMirrors() {
|
||||
rp->mirror_face = 0;
|
||||
continue;
|
||||
}
|
||||
rp->mirror_faces_list = (uint16_t *)mem_malloc(num_mirror_faces * sizeof(uint16_t));
|
||||
rp->mirror_faces_list = mem_rmalloc<uint16_t>(num_mirror_faces);
|
||||
ASSERT(rp->mirror_faces_list);
|
||||
rp->num_mirror_faces = num_mirror_faces;
|
||||
// Now go through and fill in our list
|
||||
|
@ -56,7 +56,7 @@ int AllocSpecialFace(int type, int num, bool vertnorms, int num_vertnorms) {
|
||||
|
||||
memset(&SpecialFaces[n], 0, sizeof(special_face));
|
||||
|
||||
SpecialFaces[n].spec_instance = (specular_instance *)mem_malloc(num * sizeof(specular_instance));
|
||||
SpecialFaces[n].spec_instance = mem_rmalloc<specular_instance>(num);
|
||||
ASSERT(SpecialFaces[n].spec_instance);
|
||||
|
||||
SpecialFaces[n].type = type;
|
||||
@ -65,7 +65,7 @@ int AllocSpecialFace(int type, int num, bool vertnorms, int num_vertnorms) {
|
||||
SpecialFaces[n].used = 1;
|
||||
|
||||
if (vertnorms) {
|
||||
SpecialFaces[n].vertnorms = (vector *)mem_malloc(num_vertnorms * sizeof(vector));
|
||||
SpecialFaces[n].vertnorms = mem_rmalloc<vector>(num_vertnorms);
|
||||
ASSERT(SpecialFaces[n].vertnorms);
|
||||
SpecialFaces[n].flags |= SFF_SPEC_SMOOTH;
|
||||
}
|
||||
|
@ -204,7 +204,7 @@ int AllocVClip() {
|
||||
for (i = 0; i < MAX_VCLIPS; i++) {
|
||||
if (GameVClips[i].used == 0) {
|
||||
memset(&GameVClips[i], 0, sizeof(vclip));
|
||||
GameVClips[i].frames = (int16_t *)mem_malloc(VCLIP_MAX_FRAMES * sizeof(int16_t));
|
||||
GameVClips[i].frames = mem_rmalloc<int16_t>(VCLIP_MAX_FRAMES);
|
||||
ASSERT(GameVClips[i].frames);
|
||||
GameVClips[i].frame_time = DEFAULT_FRAMETIME;
|
||||
GameVClips[i].flags = VCF_NOT_RESIDENT;
|
||||
|
@ -101,7 +101,7 @@ int AllocGamePath() {
|
||||
GamePaths[i].num_nodes = 0;
|
||||
GamePaths[i].flags = 0;
|
||||
|
||||
GamePaths[i].pathnodes = (node *)mem_malloc(MAX_NODES_PER_PATH * sizeof(node));
|
||||
GamePaths[i].pathnodes = mem_rmalloc<node>(MAX_NODES_PER_PATH);
|
||||
mprintf(0, "Path %d got some\n", i);
|
||||
|
||||
Num_game_paths++;
|
||||
|
@ -1239,7 +1239,7 @@ void FixConcaveFaces(room *rp, int *facelist, int facecount) {
|
||||
// Allocate memory for our new faces
|
||||
int nfaces = rp->num_faces + num_new_faces;
|
||||
|
||||
newfaces = (face *)mem_malloc(nfaces * sizeof(face));
|
||||
newfaces = mem_rmalloc<face>(nfaces);
|
||||
ASSERT(newfaces != NULL);
|
||||
|
||||
// Copy all the faces into our new array
|
||||
@ -1248,9 +1248,9 @@ void FixConcaveFaces(room *rp, int *facelist, int facecount) {
|
||||
if (t != facelist[i]) {
|
||||
int nverts = rp->faces[t].num_verts;
|
||||
|
||||
newfaces[t].face_verts = (int16_t *)mem_malloc(nverts * sizeof(int16_t));
|
||||
newfaces[t].face_verts = mem_rmalloc<int16_t>(nverts);
|
||||
ASSERT(newfaces[t].face_verts != NULL);
|
||||
newfaces[t].face_uvls = (roomUVL *)mem_malloc(nverts * sizeof(roomUVL));
|
||||
newfaces[t].face_uvls = mem_rmalloc<roomUVL>(nverts);
|
||||
ASSERT(newfaces[t].face_uvls != NULL);
|
||||
|
||||
newfaces[t].normal = rp->faces[t].normal;
|
||||
@ -1268,9 +1268,9 @@ void FixConcaveFaces(room *rp, int *facelist, int facecount) {
|
||||
{
|
||||
int nverts = 3;
|
||||
|
||||
newfaces[t].face_verts = (int16_t *)mem_malloc(nverts * sizeof(int16_t));
|
||||
newfaces[t].face_verts = mem_rmalloc<int16_t>(nverts);
|
||||
ASSERT(newfaces[t].face_verts != NULL);
|
||||
newfaces[t].face_uvls = (roomUVL *)mem_malloc(nverts * sizeof(roomUVL));
|
||||
newfaces[t].face_uvls = mem_rmalloc<roomUVL>(nverts);
|
||||
ASSERT(newfaces[t].face_uvls != NULL);
|
||||
|
||||
newfaces[t].tmap = rp->faces[t].tmap;
|
||||
|
@ -3456,7 +3456,7 @@ void CMainFrame::OnShowAllCheckedOut() {
|
||||
char text_buf[10000], *t;
|
||||
|
||||
// Get all locked pages
|
||||
mngs_Pagelock *LockList = (mngs_Pagelock *)mem_malloc(MAX_LOCKLIST_ELEMENTS * sizeof(mngs_Pagelock));
|
||||
mngs_Pagelock *LockList = mem_rmalloc<mngs_Pagelock>(MAX_LOCKLIST_ELEMENTS);
|
||||
int n = mng_GetListOfLocks(LockList, MAX_LOCKLIST_ELEMENTS, NULL);
|
||||
|
||||
// ASSERT(n >= 1); //always dummy page?
|
||||
|
@ -204,8 +204,8 @@ int Read3DSMaxFile(char *filename) {
|
||||
Nest_level = 0;
|
||||
|
||||
// Alloc space for reading stuff in
|
||||
Reading_room.faces = (reading_face *)mem_malloc(MAX_READING_ROOM_FACES * sizeof(reading_face));
|
||||
Reading_room.verts = (vector *)mem_malloc(MAX_VERTS_PER_ROOM * sizeof(vector));
|
||||
Reading_room.faces = mem_rmalloc<reading_face>(MAX_READING_ROOM_FACES);
|
||||
Reading_room.verts = mem_rmalloc<vector>(MAX_VERTS_PER_ROOM);
|
||||
|
||||
Reading_room.num_faces = 0;
|
||||
Reading_room.num_verts = 0;
|
||||
|
@ -1249,7 +1249,7 @@ bool CScriptLevelInterface::DeleteLevel() {
|
||||
|
||||
if (list_size == 0)
|
||||
return false;
|
||||
int *index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
int *index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return false;
|
||||
|
||||
@ -1394,7 +1394,7 @@ bool CScriptLevelInterface::DeleteScript() {
|
||||
|
||||
if (list_size == 0)
|
||||
return false;
|
||||
int *index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
int *index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return false;
|
||||
|
||||
@ -1511,7 +1511,7 @@ bool CScriptLevelInterface::CheckInScripts() {
|
||||
|
||||
if (list_size == 0)
|
||||
return false;
|
||||
int *index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
int *index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return false;
|
||||
|
||||
@ -1619,7 +1619,7 @@ bool CScriptLevelInterface::CheckInLevels() {
|
||||
|
||||
if (list_size == 0)
|
||||
return false;
|
||||
int *index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
int *index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return false;
|
||||
|
||||
@ -1759,7 +1759,7 @@ bool CScriptLevelInterface::CheckOutScripts() {
|
||||
|
||||
if (list_size == 0)
|
||||
return false;
|
||||
int *index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
int *index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return false;
|
||||
|
||||
@ -1871,7 +1871,7 @@ bool CScriptLevelInterface::CheckOutLevels() {
|
||||
|
||||
if (list_size == 0)
|
||||
return false;
|
||||
int *index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
int *index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return false;
|
||||
|
||||
@ -2015,7 +2015,7 @@ bool CScriptLevelInterface::UndoCheckOutScripts() {
|
||||
|
||||
if (list_size == 0)
|
||||
return false;
|
||||
int *index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
int *index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return false;
|
||||
|
||||
@ -2126,7 +2126,7 @@ bool CScriptLevelInterface::UndoCheckOutLevels() {
|
||||
|
||||
if (list_size == 0)
|
||||
return false;
|
||||
int *index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
int *index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return false;
|
||||
|
||||
|
@ -145,7 +145,7 @@ void CScriptMassCompile::OnBuild() {
|
||||
|
||||
if (list_size == 0)
|
||||
return;
|
||||
index_map = (int *)mem_malloc(list_size * sizeof(int));
|
||||
index_map = mem_rmalloc<int>(list_size);
|
||||
if (!index_map)
|
||||
return;
|
||||
|
||||
|
@ -952,7 +952,7 @@ void DoRadiosityForRooms() {
|
||||
|
||||
// Allocate enough memory to hold all surfaces
|
||||
|
||||
Light_surfaces = (rad_surface *)mem_malloc(facecount * sizeof(rad_surface));
|
||||
Light_surfaces = mem_rmalloc<rad_surface>(facecount);
|
||||
ASSERT(Light_surfaces != NULL);
|
||||
|
||||
// Set initial surface properties
|
||||
@ -968,7 +968,7 @@ void DoRadiosityForRooms() {
|
||||
ComputeSurfaceRes(&Light_surfaces[surface_index], &Rooms[i], t);
|
||||
|
||||
if (Rooms[i].faces[t].num_verts) {
|
||||
Light_surfaces[surface_index].verts = (vector *)mem_malloc(Rooms[i].faces[t].num_verts * sizeof(vector));
|
||||
Light_surfaces[surface_index].verts = mem_rmalloc<vector>(Rooms[i].faces[t].num_verts);
|
||||
ASSERT(Light_surfaces[surface_index].verts != NULL);
|
||||
} else {
|
||||
Light_surfaces[surface_index].verts = NULL;
|
||||
@ -1205,7 +1205,7 @@ void DoRadiosityForCurrentRoom(room *rp) {
|
||||
|
||||
// Allocate enough memory to hold all surfaces
|
||||
|
||||
Light_surfaces = (rad_surface *)mem_malloc(facecount * sizeof(rad_surface));
|
||||
Light_surfaces = mem_rmalloc<rad_surface>(facecount);
|
||||
ASSERT(Light_surfaces != NULL);
|
||||
|
||||
// Set initial surface properties
|
||||
@ -1215,7 +1215,7 @@ void DoRadiosityForCurrentRoom(room *rp) {
|
||||
ComputeSurfaceRes(&Light_surfaces[surface_index], rp, t);
|
||||
|
||||
if (rp->faces[t].num_verts) {
|
||||
Light_surfaces[surface_index].verts = (vector *)mem_malloc(rp->faces[t].num_verts * sizeof(vector));
|
||||
Light_surfaces[surface_index].verts = mem_rmalloc<vector>(rp->faces[t].num_verts);
|
||||
ASSERT(Light_surfaces[surface_index].verts != NULL);
|
||||
} else {
|
||||
Light_surfaces[surface_index].verts = NULL;
|
||||
@ -1877,7 +1877,7 @@ void DoRadiosityForTerrain() {
|
||||
terrain_sums[1] = (spectra *)mem_malloc(TERRAIN_WIDTH * TERRAIN_DEPTH * sizeof(spectra));
|
||||
ASSERT(terrain_sums[0] && terrain_sums[1]);
|
||||
|
||||
Light_surfaces = (rad_surface *)mem_malloc(total_surfaces * sizeof(rad_surface));
|
||||
Light_surfaces = mem_rmalloc<rad_surface>(total_surfaces);
|
||||
ASSERT(Light_surfaces != NULL);
|
||||
|
||||
// Setup radiosity surfaces
|
||||
@ -2041,7 +2041,7 @@ void DoRadiosityForTerrain() {
|
||||
|
||||
ComputeSurfaceRes(&Light_surfaces[surf_index], &Rooms[i], t);
|
||||
|
||||
Light_surfaces[surf_index].verts = (vector *)mem_malloc(Rooms[i].faces[t].num_verts * sizeof(vector));
|
||||
Light_surfaces[surf_index].verts = mem_rmalloc<vector>(Rooms[i].faces[t].num_verts);
|
||||
ASSERT(Light_surfaces[surf_index].verts != NULL);
|
||||
|
||||
Light_surfaces[surf_index].elements = (rad_element *)mem_malloc(
|
||||
|
@ -314,7 +314,7 @@ int ComputeSurfacesForObjects(int surface_index, int terrain) {
|
||||
ComputeObjectSurfaceRes(&Light_surfaces[surface_index], &Objects[i], t, j);
|
||||
|
||||
if (sm->faces[j].nverts > 0) {
|
||||
Light_surfaces[surface_index].verts = (vector *)mem_malloc(sm->faces[j].nverts * sizeof(vector));
|
||||
Light_surfaces[surface_index].verts = mem_rmalloc<vector>(sm->faces[j].nverts);
|
||||
ASSERT(Light_surfaces[surface_index].verts != NULL);
|
||||
} else
|
||||
Light_surfaces[surface_index].verts = NULL;
|
||||
@ -400,7 +400,7 @@ int ComputeSurfacesForObjectsForSingleRoom(int surface_index, int roomnum) {
|
||||
ComputeObjectSurfaceRes(&Light_surfaces[surface_index], &Objects[i], t, j);
|
||||
|
||||
if (sm->faces[j].nverts > 0) {
|
||||
Light_surfaces[surface_index].verts = (vector *)mem_malloc(sm->faces[j].nverts * sizeof(vector));
|
||||
Light_surfaces[surface_index].verts = mem_rmalloc<vector>(sm->faces[j].nverts);
|
||||
ASSERT(Light_surfaces[surface_index].verts != NULL);
|
||||
} else
|
||||
Light_surfaces[surface_index].verts = NULL;
|
||||
|
@ -125,7 +125,7 @@ void InitRadiosityRun() {
|
||||
void SetupFormFactors() {
|
||||
ASSERT(rad_NumElements > 0);
|
||||
|
||||
rad_FormFactors = (float *)mem_malloc(rad_NumElements * sizeof(float));
|
||||
rad_FormFactors = mem_rmalloc<float>(rad_NumElements);
|
||||
ASSERT(rad_FormFactors != NULL);
|
||||
}
|
||||
|
||||
|
@ -1021,7 +1021,7 @@ int d3d_TextureCacheInit() {
|
||||
}
|
||||
|
||||
// Allocate room to hold all our surfaces
|
||||
UploadSurfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(NUM_TEXTURE_CLASSES * sizeof(LPDIRECTDRAWSURFACE4));
|
||||
UploadSurfaces = mem_rmalloc<LPDIRECTDRAWSURFACE4>(NUM_TEXTURE_CLASSES);
|
||||
if (UploadSurfaces == NULL) {
|
||||
mprintf(0, "Couldn't allocate memory for UploadSurfaces!\n");
|
||||
|
||||
@ -1030,7 +1030,7 @@ int d3d_TextureCacheInit() {
|
||||
}
|
||||
|
||||
// Allocate room to hold all our 4444 surfaces
|
||||
Upload4444Surfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(NUM_TEXTURE_CLASSES * sizeof(LPDIRECTDRAWSURFACE4));
|
||||
Upload4444Surfaces = mem_rmalloc<LPDIRECTDRAWSURFACE4>(NUM_TEXTURE_CLASSES);
|
||||
if (Upload4444Surfaces == NULL) {
|
||||
mprintf(0, "Couldn't allocate memory for Upload4444Surfaces!\n");
|
||||
|
||||
@ -1038,7 +1038,7 @@ int d3d_TextureCacheInit() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
BitmapTextureSurfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(MAX_BITMAPS * sizeof(LPDIRECTDRAWSURFACE4));
|
||||
BitmapTextureSurfaces = mem_rmalloc<LPDIRECTDRAWSURFACE4>(MAX_BITMAPS);
|
||||
if (BitmapTextureSurfaces == NULL) {
|
||||
mprintf(0, "Couldn't allocate memory for BitmapTextureSurfaces!\n");
|
||||
|
||||
@ -1047,7 +1047,7 @@ int d3d_TextureCacheInit() {
|
||||
}
|
||||
|
||||
// Allocate room to hold all our surfaces
|
||||
LightmapTextureSurfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(MAX_LIGHTMAPS * sizeof(LPDIRECTDRAWSURFACE4));
|
||||
LightmapTextureSurfaces = mem_rmalloc<LPDIRECTDRAWSURFACE4>(MAX_LIGHTMAPS);
|
||||
if (LightmapTextureSurfaces == NULL) {
|
||||
mprintf(0, "Couldn't allocate memory for LightmapTextureSurfaces!\n");
|
||||
rend_SetErrorMessage("Couldn't alloc mem for LightmapTextureSurfaces!");
|
||||
@ -1055,7 +1055,7 @@ int d3d_TextureCacheInit() {
|
||||
}
|
||||
|
||||
if (d3d_CanBumpmap) {
|
||||
BumpmapTextureSurfaces = (LPDIRECTDRAWSURFACE4 *)mem_malloc(MAX_BUMPMAPS * sizeof(LPDIRECTDRAWSURFACE4));
|
||||
BumpmapTextureSurfaces = mem_rmalloc<LPDIRECTDRAWSURFACE4>(MAX_BUMPMAPS);
|
||||
if (BumpmapTextureSurfaces == NULL) {
|
||||
mprintf(0, "Couldn't allocate memory for BumpmapTextureSurfaces!\n");
|
||||
rend_SetErrorMessage("Couldn't alloc mem for BumpmapTextureSurfaces!");
|
||||
|
@ -629,9 +629,9 @@ int mng_InitTableFiles() {
|
||||
// Loads our tables
|
||||
int mng_LoadTableFiles(int show_progress) {
|
||||
if (Network_up) {
|
||||
LockList = (mngs_Pagelock *)mem_malloc(MAX_LOCKLIST_ELEMENTS * sizeof(mngs_Pagelock));
|
||||
LockList = mem_rmalloc<mngs_Pagelock>(MAX_LOCKLIST_ELEMENTS);
|
||||
Num_locklist = mng_GetListOfLocks(LockList, MAX_LOCKLIST_ELEMENTS, TableUser);
|
||||
OldFiles = (old_file *)mem_malloc(MAX_OLDFILE_ELEMENTS * sizeof(old_file));
|
||||
OldFiles = mem_rmalloc<old_file>(MAX_OLDFILE_ELEMENTS);
|
||||
Num_old_files = 0;
|
||||
ASSERT(OldFiles);
|
||||
#if defined(WIN32)
|
||||
@ -2735,7 +2735,7 @@ bool mng_SetAddonTable(char *name) {
|
||||
|
||||
strcpy(AddOnDataTables[Num_addon_tables].AddOnTableFilename, name);
|
||||
AddOnDataTables[Num_addon_tables].Addon_tracklocks =
|
||||
(mngs_track_lock *)mem_malloc(MAX_ADDON_TRACKLOCKS * sizeof(mngs_track_lock));
|
||||
mem_rmalloc<mngs_track_lock>(MAX_ADDON_TRACKLOCKS);
|
||||
AddOnDataTables[Num_addon_tables].Num_addon_tracklocks = 0;
|
||||
ASSERT(AddOnDataTables[Num_addon_tables].Addon_tracklocks);
|
||||
memset(AddOnDataTables[Num_addon_tables].Addon_tracklocks, 0, MAX_ADDON_TRACKLOCKS * sizeof(mngs_track_lock));
|
||||
|
@ -1419,9 +1419,9 @@ int ReadNewModelFile(int polynum, CFILE *infile) {
|
||||
ASSERT(nverts < MAX_POLYGON_VECS);
|
||||
|
||||
if (nverts) {
|
||||
pm->submodel[n].verts = (vector *)mem_malloc(nverts * sizeof(vector));
|
||||
pm->submodel[n].vertnorms = (vector *)mem_malloc(nverts * sizeof(vector));
|
||||
pm->submodel[n].alpha = (float *)mem_malloc(nverts * sizeof(float));
|
||||
pm->submodel[n].verts = mem_rmalloc<vector>(nverts);
|
||||
pm->submodel[n].vertnorms = mem_rmalloc<vector>(nverts);
|
||||
pm->submodel[n].alpha = mem_rmalloc<float>(nverts);
|
||||
ASSERT(pm->submodel[n].verts);
|
||||
ASSERT(pm->submodel[n].vertnorms);
|
||||
ASSERT(pm->submodel[n].alpha);
|
||||
@ -1474,9 +1474,9 @@ int ReadNewModelFile(int polynum, CFILE *infile) {
|
||||
pm->submodel[n].num_faces = nfaces;
|
||||
|
||||
if (nfaces) {
|
||||
pm->submodel[n].faces = (polyface *)mem_malloc(nfaces * sizeof(polyface));
|
||||
pm->submodel[n].face_min = (vector *)mem_malloc(nfaces * sizeof(vector));
|
||||
pm->submodel[n].face_max = (vector *)mem_malloc(nfaces * sizeof(vector));
|
||||
pm->submodel[n].faces = mem_rmalloc<polyface>(nfaces);
|
||||
pm->submodel[n].face_min = mem_rmalloc<vector>(nfaces);
|
||||
pm->submodel[n].face_max = mem_rmalloc<vector>(nfaces);
|
||||
ASSERT(pm->submodel[n].faces);
|
||||
} else {
|
||||
pm->submodel[n].faces = nullptr;
|
||||
@ -1524,13 +1524,13 @@ int ReadNewModelFile(int polynum, CFILE *infile) {
|
||||
|
||||
// Allocate our space
|
||||
if (current_count) {
|
||||
sm->vertnum_memory = (int16_t *)mem_malloc(current_count * sizeof(int16_t));
|
||||
sm->vertnum_memory = mem_rmalloc<int16_t>(current_count);
|
||||
ASSERT(sm->vertnum_memory);
|
||||
|
||||
sm->u_memory = (float *)mem_malloc(current_count * sizeof(float));
|
||||
sm->u_memory = mem_rmalloc<float>(current_count);
|
||||
ASSERT(sm->u_memory);
|
||||
|
||||
sm->v_memory = (float *)mem_malloc(current_count * sizeof(float));
|
||||
sm->v_memory = mem_rmalloc<float>(current_count);
|
||||
ASSERT(sm->v_memory);
|
||||
} else {
|
||||
sm->vertnum_memory = nullptr;
|
||||
|
@ -457,7 +457,7 @@ char SoundLoadWaveFile(const char *filename, float percent_volume, int sound_fil
|
||||
|
||||
} else if (SoundFiles[sound_file_index].sample_16bit == NULL && f_high_quality) {
|
||||
SoundFiles[sound_file_index].sample_16bit =
|
||||
(int16_t *)mem_malloc(SoundFiles[sound_file_index].sample_length * sizeof(int16_t));
|
||||
mem_rmalloc<int16_t>(SoundFiles[sound_file_index].sample_length);
|
||||
|
||||
// NOTE: Interesting note on sound conversion: 16 bit sounds are signed (0 biase). 8 bit sounds are unsigned
|
||||
// (+128 biase).
|
||||
|
Loading…
Reference in New Issue
Block a user