From 9f58c947fc90eaa0a9f0133d195bc1264d464c25 Mon Sep 17 00:00:00 2001 From: Steam Deck User Date: Thu, 2 Feb 2023 12:44:45 -0500 Subject: [PATCH] Actually use Q_malloc in a lot of places --- source/crypter.c | 4 ++-- source/menu.c | 28 +++++++++++++------------- source/psp/system.cpp | 4 ++-- source/psp/video_hardware_QMB.cpp | 3 ++- source/psp/video_hardware_draw.cpp | 1 - source/psp/video_hardware_misc.cpp | 2 +- source/psp/video_hardware_model.cpp | 1 - source/psp/video_hardware_resample.cpp | 5 ++--- source/psp/wad3.cpp | 8 ++++---- 9 files changed, 27 insertions(+), 29 deletions(-) diff --git a/source/crypter.c b/source/crypter.c index 68a8bb2..0a8d69e 100644 --- a/source/crypter.c +++ b/source/crypter.c @@ -42,7 +42,7 @@ char decrypt(char c, int key) char *strencrypt(char *s, int key, int len) { int i; - char *result = malloc(len); + char *result = Q_malloc(len); for(i = 0; i < len; i++) { result[i] = encrypt(s[i], key); @@ -55,7 +55,7 @@ char *strencrypt(char *s, int key, int len) char *strdecrypt(char *s, int key, int len) { int i; - char *result = malloc(len); + char *result = Q_malloc(len); for(i = 0; i < len; i++) { result[i] = decrypt(s[i], -key); diff --git a/source/menu.c b/source/menu.c index 2fe3468..cf2546c 100644 --- a/source/menu.c +++ b/source/menu.c @@ -1445,7 +1445,7 @@ void M_Achievement_Draw (void) int maxLenght = floor((vid.width - 155)/8); int stringLenght; char *description; - char *string_line = (char*) malloc(maxLenght); + char *string_line = (char*) Q_malloc(maxLenght); int lines; y = 0; @@ -4925,15 +4925,15 @@ void Map_Finder(void) COM_StripExtension(dirent.d_name, ntype); custom_maps[user_maps_num].occupied = true; - custom_maps[user_maps_num].map_name = malloc(sizeof(char)*32); + custom_maps[user_maps_num].map_name = Q_malloc(sizeof(char)*32); sprintf(custom_maps[user_maps_num].map_name, "%s", ntype); char* setting_path; int setting_file; SceIoStat setting_info; - setting_path = malloc(sizeof(char)*64); - custom_maps[user_maps_num].map_thumbnail_path = malloc(sizeof(char)*64); + setting_path = Q_malloc(sizeof(char)*64); + custom_maps[user_maps_num].map_thumbnail_path = Q_malloc(sizeof(char)*64); #ifdef KERNEL_MODE strcpy(setting_path, va("%s/maps/", com_gamedir)); #else @@ -4953,16 +4953,16 @@ void Map_Finder(void) state = 0; int value; - custom_maps[user_maps_num].map_name_pretty = malloc(sizeof(char)*32); - custom_maps[user_maps_num].map_desc_1 = malloc(sizeof(char)*40); - custom_maps[user_maps_num].map_desc_2 = malloc(sizeof(char)*40); - custom_maps[user_maps_num].map_desc_3 = malloc(sizeof(char)*40); - custom_maps[user_maps_num].map_desc_4 = malloc(sizeof(char)*40); - custom_maps[user_maps_num].map_desc_5 = malloc(sizeof(char)*40); - custom_maps[user_maps_num].map_desc_6 = malloc(sizeof(char)*40); - custom_maps[user_maps_num].map_desc_7 = malloc(sizeof(char)*40); - custom_maps[user_maps_num].map_desc_8 = malloc(sizeof(char)*40); - custom_maps[user_maps_num].map_author = malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_name_pretty = Q_malloc(sizeof(char)*32); + custom_maps[user_maps_num].map_desc_1 = Q_malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_desc_2 = Q_malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_desc_3 = Q_malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_desc_4 = Q_malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_desc_5 = Q_malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_desc_6 = Q_malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_desc_7 = Q_malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_desc_8 = Q_malloc(sizeof(char)*40); + custom_maps[user_maps_num].map_author = Q_malloc(sizeof(char)*40); char* buffer = (char*)calloc(setting_info.st_size+1, sizeof(char)); sceIoRead(setting_file, buffer, setting_info.st_size); diff --git a/source/psp/system.cpp b/source/psp/system.cpp index 6990fa6..4398e0d 100644 --- a/source/psp/system.cpp +++ b/source/psp/system.cpp @@ -474,13 +474,13 @@ char *Sys_FindFirstFile (char *path, char *pattern) return NULL; tmp_len = strlen (pattern); - findpattern = (char*) malloc (tmp_len + 1); + findpattern = (char*) Q_malloc (tmp_len + 1); if (!findpattern) return NULL; strcpy (findpattern, pattern); findpattern[tmp_len] = '\0'; tmp_len = strlen (path); - findpath = (char*) malloc (tmp_len + 1); + findpath = (char*) Q_malloc (tmp_len + 1); if (!findpath) return NULL; strcpy (findpath, path); diff --git a/source/psp/video_hardware_QMB.cpp b/source/psp/video_hardware_QMB.cpp index 8a1fbe7..c9e17a6 100644 --- a/source/psp/video_hardware_QMB.cpp +++ b/source/psp/video_hardware_QMB.cpp @@ -420,7 +420,8 @@ void QMB_AllocParticles (void) Con_Printf("QMB_AllocParticles: internal error >num particles<\n"); // can't alloc on Hunk, using native memory - particles = (particle_t *) malloc (r_numparticles * sizeof(particle_t)); + // why??????? why not?????? where's the context :$ + particles = (particle_t *) Q_malloc (r_numparticles * sizeof(particle_t)); } void QMB_InitParticles (void) diff --git a/source/psp/video_hardware_draw.cpp b/source/psp/video_hardware_draw.cpp index 092c27b..e033b71 100644 --- a/source/psp/video_hardware_draw.cpp +++ b/source/psp/video_hardware_draw.cpp @@ -25,7 +25,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -#include #include #include #include diff --git a/source/psp/video_hardware_misc.cpp b/source/psp/video_hardware_misc.cpp index da60ffb..7f413ab 100644 --- a/source/psp/video_hardware_misc.cpp +++ b/source/psp/video_hardware_misc.cpp @@ -192,7 +192,7 @@ void R_Envmap_f (void) { byte *buffer; - buffer = static_cast(malloc(ENVMAP_SIZE)); + buffer = static_cast(Q_malloc(ENVMAP_SIZE)); if(!buffer) { Con_Printf("ENV MAP FAILED, buffer not created\n"); diff --git a/source/psp/video_hardware_model.cpp b/source/psp/video_hardware_model.cpp index 328bd00..b6f971e 100644 --- a/source/psp/video_hardware_model.cpp +++ b/source/psp/video_hardware_model.cpp @@ -28,7 +28,6 @@ extern "C" { #include "../quakedef.h" } -#include #include diff --git a/source/psp/video_hardware_resample.cpp b/source/psp/video_hardware_resample.cpp index 4514880..c7338aa 100644 --- a/source/psp/video_hardware_resample.cpp +++ b/source/psp/video_hardware_resample.cpp @@ -1,4 +1,3 @@ -#include #include extern "C" @@ -57,7 +56,7 @@ static void Image_Resample32 (void *indata, int inwidth, int inheight,void *outd out = static_cast(outdata); fstep = (int) (inheight * 65536.0f / outheight); - memalloc = static_cast(malloc(2 * outwidth4)); + memalloc = static_cast(Q_malloc(2 * outwidth4)); row1 = memalloc; row2 = memalloc + outwidth4; inrow = (byte *) indata; @@ -207,7 +206,7 @@ static void Image_Resample24 (void *indata, int inwidth, int inheight, out = static_cast(outdata); fstep = (int) (inheight * 65536.0f / outheight); - memalloc = static_cast(malloc(2 * outwidth3)); + memalloc = static_cast(Q_malloc(2 * outwidth3)); row1 = memalloc; row2 = memalloc + outwidth3; inrow = (byte *) indata; diff --git a/source/psp/wad3.cpp b/source/psp/wad3.cpp index 951a5ab..ee74e48 100644 --- a/source/psp/wad3.cpp +++ b/source/psp/wad3.cpp @@ -168,7 +168,7 @@ int ConvertWad3ToRGBA(miptex_t *tex) pal = in + ((image_size * 85) >> 6) + 2; - data = (byte*)malloc(image_size); + data = (byte*)Q_malloc(image_size); for (i = 0; i < image_size; i++) { p = *in++; @@ -369,7 +369,7 @@ void W_LoadTextureWadFileHL (char *filename, int complain) return; } - if (!(lumps = static_cast(malloc(sizeof(lumpinfo_t)*numlumps)))) + if (!(lumps = static_cast(Q_malloc(sizeof(lumpinfo_t)*numlumps)))) { fclose(file); Con_Printf ("W_LoadTextureWadFile: unable to allocate temporary memory for lump table"); @@ -415,7 +415,7 @@ byte *W_ConvertWAD3TextureHL(miptex_t *tex) int d, p, image_size; in = (byte *)((int) tex + tex->offsets[0]); - data = out = static_cast(malloc(tex->width * tex->height * 4)); + data = out = static_cast(Q_malloc(tex->width * tex->height * 4)); if (!data) return NULL; @@ -468,7 +468,7 @@ byte *W_GetTextureHL(char *name) return NULL; } - tex = static_cast(malloc(texwadlump[i].size)); + tex = static_cast(Q_malloc(texwadlump[i].size)); if (!tex) return NULL;