always use Hunk_AllocName instead of Hunk_Alloc

master
an 2019-12-04 07:24:35 -05:00
parent 0ce5d4e078
commit 163560269a
15 changed files with 35 additions and 45 deletions

View File

@ -693,7 +693,7 @@ void Cmd_AddCommand(const char *cmd_name, xcommand_t function)
}
}
cmd = (cmd_function_t *) Hunk_Alloc(sizeof(cmd_function_t));
cmd = Hunk_AllocName(sizeof(cmd_function_t), "cmd_functions");
cmd->name = cmd_name;
cmd->function = function;

View File

@ -274,7 +274,7 @@ void Con_CheckResize(void)
numchars = con_linewidth;
mark = Hunk_LowMark(); //johnfitz
tbuf = (char *) Hunk_Alloc(con_buffersize); //johnfitz
tbuf = Hunk_AllocName(con_buffersize, __func__); //johnfitz
Q_memcpy(tbuf, con_text, con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
Q_memset(con_text, ' ', con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
@ -314,7 +314,7 @@ void Con_Init(void)
con_buffersize = CON_TEXTSIZE;
//johnfitz
con_text = (char *) Hunk_AllocName(con_buffersize, "context"); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
con_text = (char *)Hunk_AllocName(con_buffersize, "con_text"); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
Q_memset(con_text, ' ', con_buffersize); //johnfitz -- con_buffersize replaces CON_TEXTSIZE
con_linewidth = -1;
@ -771,7 +771,7 @@ void AddToTabList(const char *name, const char *type)
*i_bash = 0;
}
t = (tab_t *) Hunk_Alloc(sizeof(tab_t));
t = Hunk_AllocName(sizeof(tab_t), __func__);
t->name = name;
t->type = type;

View File

@ -326,7 +326,7 @@ qpic_t *Draw_MakePic(const char *name, int32_t width, int32_t height, byte *data
qpic_t *pic;
glpic_t gl;
pic = (qpic_t *) Hunk_Alloc(sizeof(qpic_t) - 4 + sizeof(glpic_t));
pic = Hunk_AllocName(sizeof(qpic_t) - 4 + sizeof(glpic_t), __func__);
pic->width = width;
pic->height = height;

View File

@ -320,7 +320,7 @@ void GL_MakeAliasModelDisplayLists(qmodel_t *m, aliashdr_t *hdr)
paliashdr->poseverts = numorder;
cmds = (int32_t *) Hunk_Alloc(numcommands * 4);
cmds = Hunk_AllocName(numcommands * 4, __func__);
paliashdr->commands = (byte *)cmds - (byte *)paliashdr;
//johnfitz -- precompute texcoords for padded skins
@ -344,7 +344,7 @@ void GL_MakeAliasModelDisplayLists(qmodel_t *m, aliashdr_t *hdr)
}
//johnfitz
verts = (trivertx_t *) Hunk_Alloc(paliashdr->numposes * paliashdr->poseverts * sizeof(trivertx_t));
verts = Hunk_AllocName(paliashdr->numposes * paliashdr->poseverts * sizeof(trivertx_t), __func__);
paliashdr->posedata = (byte *)verts - (byte *)paliashdr;
for(i = 0 ; i < paliashdr->numposes ; i++)
for(j = 0 ; j < numorder ; j++)
@ -379,7 +379,7 @@ void GL_MakeAliasModelDisplayLists_VBO(void)
return;
// first, copy the verts onto the hunk
verts = (trivertx_t *) Hunk_Alloc(paliashdr->numposes * paliashdr->numverts * sizeof(trivertx_t));
verts = Hunk_AllocName(paliashdr->numposes * paliashdr->numverts * sizeof(trivertx_t), __func__);
paliashdr->vertexes = (byte *)verts - (byte *)paliashdr;
for(i = 0 ; i < paliashdr->numposes ; i++)
for(j = 0 ; j < paliashdr->numverts ; j++)
@ -387,10 +387,10 @@ void GL_MakeAliasModelDisplayLists_VBO(void)
// there can never be more than this number of verts and we just put them all on the hunk
maxverts_vbo = pheader->numtris * 3;
desc = (aliasmesh_t *) Hunk_Alloc(sizeof(aliasmesh_t) * maxverts_vbo);
desc = Hunk_AllocName(sizeof(aliasmesh_t) * maxverts_vbo, __func__);
// there will always be this number of indexes
indexes = (uint16_t *) Hunk_Alloc(sizeof(uint16_t) * maxverts_vbo);
indexes = Hunk_AllocName(sizeof(uint16_t) * maxverts_vbo, __func__);
pheader->indexes = (intptr_t) indexes - (intptr_t) pheader;
pheader->meshdesc = (intptr_t) desc - (intptr_t) pheader;

View File

@ -529,7 +529,7 @@ void Mod_LoadTextures(lump_t *l)
}
//now create the warpimage, using dummy data from the hunk to create the initial image
Hunk_Alloc(gl_warpimagesize * gl_warpimagesize * 4); //make sure hunk is big enough so we don't reach an illegal address
Hunk_AllocName(gl_warpimagesize * gl_warpimagesize * 4, "temporary check"); //make sure hunk is big enough so we don't reach an illegal address
Hunk_FreeToLowMark(mark);
q_snprintf(texturename, sizeof(texturename), "%s_warp", texturename);
tx->warpimage = TexMgr_LoadImage(loadmodel, texturename, gl_warpimagesize,
@ -1083,7 +1083,7 @@ void Mod_PolyForUnlitSurface(msurface_t *fa)
}
//create the poly
poly = (glpoly_t *) Hunk_Alloc(sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float));
poly = Hunk_AllocName(sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float), __func__);
poly->next = NULL;
fa->polys = poly;
poly->numverts = numverts;

View File

@ -56,7 +56,7 @@ entity_t *r_addent;
// based on RMQEngine
static efrag_t *R_GetEfrag(void)
{
// we could just Hunk_Alloc a single efrag_t and return it, but since
// we could just allocate a single efrag_t and return it, but since
// the struct is so small (2 pointers) allocate groups of them
// to avoid wasting too much space on the hunk allocation headers.

View File

@ -98,8 +98,8 @@ void Sky_LoadTexture(texture_t *mt)
char texturename[64];
int32_t i, j, p, r, g, b, count;
byte *src;
static byte front_data[128 * 128]; //FIXME: Hunk_Alloc
static byte back_data[128 * 128]; //FIXME: Hunk_Alloc
static byte front_data[128 * 128]; //FIXME: dynamically allocate
static byte back_data[128 * 128]; //FIXME: dynamically allocate
unsigned *rgba;
src = (byte *)mt + mt->offsets[0];
@ -609,7 +609,7 @@ void Sky_ProcessEntities(void)
{
//copy the polygon and translate manually, since Sky_ProcessPoly needs it to be in world space
mark = Hunk_LowMark();
p = (glpoly_t *) Hunk_Alloc(sizeof(*s->polys)); //FIXME: don't allocate for each poly
p = Hunk_AllocName(sizeof(*s->polys), __func__); //FIXME: don't allocate for each poly
p->numverts = s->polys->numverts;
for(k = 0; k < p->numverts; k++)
{
@ -908,7 +908,7 @@ void Sky_DrawFace(int32_t axis)
Sky_SetBoxVert(1.0, -1.0, axis, verts[3]);
start = Hunk_LowMark();
p = (glpoly_t *) Hunk_Alloc(sizeof(glpoly_t));
p = Hunk_AllocName(sizeof(glpoly_t), __func__);
VectorSubtract(verts[2], verts[3], vup);
VectorSubtract(verts[2], verts[1], vright);

View File

@ -474,7 +474,7 @@ void TexMgr_LoadPalette(void)
Sys_Error("Couldn't load gfx/palette.lmp");
mark = Hunk_LowMark();
pal = (byte *) Hunk_Alloc(768);
pal = Hunk_AllocName(768, __func__);
fread(pal, 1, 768, f);
fclose(f);
@ -576,7 +576,7 @@ void TexMgr_RecalcWarpImageSize(void)
// resize the textures in opengl
mark = Hunk_LowMark();
dummy = (byte *) Hunk_Alloc(gl_warpimagesize * gl_warpimagesize * 4);
dummy = Hunk_AllocName(gl_warpimagesize * gl_warpimagesize * 4, __func__);
for(glt = active_gltextures; glt; glt = glt->next)
{
@ -760,7 +760,7 @@ static unsigned *TexMgr_ResampleTexture(unsigned *in, int32_t inwidth, int32_t i
outwidth = TexMgr_Pad(inwidth);
outheight = TexMgr_Pad(inheight);
out = (unsigned *) Hunk_Alloc(outwidth * outheight * 4);
out = Hunk_AllocName(outwidth * outheight * 4, __func__);
xfrac = ((inwidth - 1) << 16) / (outwidth - 1);
yfrac = ((inheight - 1) << 16) / (outheight - 1);
@ -998,7 +998,7 @@ static unsigned *TexMgr_8to32(byte *in, int32_t pixels, uint32_t *usepal)
int32_t i;
unsigned *out, *data;
out = data = (unsigned *) Hunk_Alloc(pixels * 4);
out = data = Hunk_AllocName(pixels * 4, __func__);
for(i = 0; i < pixels; i++)
*out++ = usepal[*in++];
@ -1021,7 +1021,7 @@ static byte *TexMgr_PadImageW(byte *in, int32_t width, int32_t height, byte padb
outwidth = TexMgr_Pad(width);
out = data = (byte *) Hunk_Alloc(outwidth * height);
out = data = Hunk_AllocName(outwidth * height, __func__);
for(i = 0; i < height; i++)
{
@ -1050,7 +1050,7 @@ static byte *TexMgr_PadImageH(byte *in, int32_t width, int32_t height, byte padb
srcpix = width * height;
dstpix = width * TexMgr_Pad(height);
out = data = (byte *) Hunk_Alloc(dstpix);
out = data = Hunk_AllocName(dstpix, __func__);
for(i = 0; i < srcpix; i++)
*out++ = *in++;
@ -1349,7 +1349,7 @@ void TexMgr_ReloadImage(gltexture_t *glt, int32_t shirt, int32_t pants)
size *= 4;
else if(glt->source_format == SRC_LIGHTMAP)
size *= lightmap_bytes;
data = (byte *) Hunk_Alloc(size);
data = Hunk_AllocName(size, __func__);
fread(data, 1, size, f);
fclose(f);
}
@ -1415,7 +1415,7 @@ invalid:
//translate texture
size = glt->width * glt->height;
dst = translated = (byte *) Hunk_Alloc(size);
dst = translated = Hunk_AllocName(size, __func__);
src = data;
for(i = 0; i < size; i++)

View File

@ -138,7 +138,7 @@ void SubdividePolygon(int32_t numverts, float *verts)
return;
}
poly = (glpoly_t *) Hunk_Alloc(sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float));
poly = Hunk_AllocName(sizeof(glpoly_t) + (numverts - 4) * VERTEXSIZE * sizeof(float), __func__);
poly->next = warpface->polys->next;
warpface->polys->next = poly;
poly->numverts = numverts;

View File

@ -214,7 +214,7 @@ byte *Image_LoadTGA(FILE *fin, int32_t *width, int32_t *height)
numPixels = columns * rows;
upside_down = !(targa_header.attributes & 0x20); //johnfitz -- fix for upside-down targas
targa_rgba = (byte *) Hunk_Alloc(numPixels * 4);
targa_rgba = Hunk_AllocName(numPixels * 4, __func__);
if(targa_header.id_length != 0)
fseek(fin, targa_header.id_length, SEEK_CUR); // skip TARGA image comment
@ -424,7 +424,7 @@ byte *Image_LoadPCX(FILE *f, int32_t *width, int32_t *height)
w = pcx.xmax - pcx.xmin + 1;
h = pcx.ymax - pcx.ymin + 1;
data = (byte *) Hunk_Alloc((w * h + 1) * 4); //+1 to allow reading padding byte on last line
data = Hunk_AllocName((w * h + 1) * 4, __func__); //+1 to allow reading padding byte on last line
//load palette
fseek(f, start + com_filesize - 768, SEEK_SET);

View File

@ -444,7 +444,7 @@ void BuildSurfaceDisplayList(msurface_t *fa)
//
// draw texture
//
poly = (glpoly_t *) Hunk_Alloc(sizeof(glpoly_t) + (lnumverts - 4) * VERTEXSIZE * sizeof(float));
poly = Hunk_AllocName(sizeof(glpoly_t) + (lnumverts - 4) * VERTEXSIZE * sizeof(float), __func__);
poly->next = fa->polys;
fa->polys = poly;
poly->numverts = lnumverts;

View File

@ -482,8 +482,8 @@ void SV_PushMove(edict_t *pusher, float movetime)
//johnfitz -- dynamically allocate
mark = Hunk_LowMark();
moved_edict = (edict_t **) Hunk_Alloc(sv.num_edicts * sizeof(edict_t *));
moved_from = (vec3_t *) Hunk_Alloc(sv.num_edicts * sizeof(vec3_t));
moved_edict = Hunk_AllocName(sv.num_edicts * sizeof(edict_t *), "moved_edict");
moved_from = Hunk_AllocName(sv.num_edicts * sizeof(vec3_t), "moved_from");
//johnfitz
// see if any solid entities are inside the final position

View File

@ -343,7 +343,7 @@ void SV_TouchLinks(edict_t *ent)
int32_t mark;
mark = Hunk_LowMark();
list = (edict_t **) Hunk_Alloc(sv.num_edicts * sizeof(edict_t *));
list = Hunk_AllocName(sv.num_edicts * sizeof(edict_t *), __func__);
listcount = 0;
SV_AreaTriggerEdicts(ent, sv_areanodes, list, &listcount, sv.num_edicts);

View File

@ -438,12 +438,12 @@ void *Hunk_AllocName(int32_t size, const char *name)
#endif
if(size < 0)
Sys_Error("Hunk_Alloc: bad size: %" PRIi32 "", size);
Sys_Error("Hunk_AllocName: bad size: %" PRIi32 "", size);
size = sizeof(hunk_t) + ((size + 15) & ~15);
if(hunk_size - hunk_low_used - hunk_high_used < size)
Sys_Error("Hunk_Alloc: failed on %" PRIi32 " bytes", size);
Sys_Error("Hunk_AllocName: failed on %" PRIi32 " bytes", size);
h = (hunk_t *)(hunk_base + hunk_low_used);
hunk_low_used += size;
@ -459,16 +459,6 @@ void *Hunk_AllocName(int32_t size, const char *name)
return h + 1;
}
/*
===================
Hunk_Alloc
===================
*/
void *Hunk_Alloc(int32_t size)
{
return Hunk_AllocName(size, "unknown");
}
int32_t Hunk_LowMark(void)
{
return hunk_low_used;

View File

@ -96,7 +96,6 @@ void *Z_Malloc(int32_t size); // returns 0 filled memory
void *Z_Realloc(void *ptr, int32_t size);
char *Z_Strdup(const char *s);
void *Hunk_Alloc(int32_t size); // returns 0 filled memory
void *Hunk_AllocName(int32_t size, const char *name);
void *Hunk_HighAllocName(int32_t size, const char *name);
void *Hunk_Strdup(void const *s, char const *name);
@ -111,6 +110,7 @@ void Hunk_FreeToHighMark(int32_t mark);
void *Hunk_TempAlloc(int32_t size);
void Hunk_Check(void);
void Hunk_Print(bool all);
typedef struct cache_user_s
{