}
}
- cmd = Hunk_Alloc (sizeof(cmd_function_t));
+ cmd = Hunk_AllocName (sizeof(cmd_function_t), "commands");
cmd->name = cmd_name;
cmd->function = function;
cmd->next = cmd_functions;
// extract the filename base name for hunk tag
COM_FileBase (path, base);
- if (usehunk == 1)
- buf = Hunk_AllocName (len+1, base);
- else if (usehunk == 2)
- buf = Hunk_TempAlloc (len+1);
- else if (usehunk == 0)
- buf = Z_Malloc (len+1);
- else if (usehunk == 3)
- buf = Cache_Alloc (loadcache, len+1, base);
- else if (usehunk == 4)
+ switch (usehunk)
{
- if (len+1 > loadsize)
- buf = Hunk_TempAlloc (len+1);
- else
- buf = loadbuf;
- }
- else if (usehunk == 5)
+ case 1:
+ buf = Hunk_AllocName (len+1, va("%s (file)", path));
+ break;
+// case 0:
+// buf = Z_Malloc (len+1);
+// break;
+ case 3:
+ buf = Cache_Alloc (loadcache, len+1, base);
+ break;
+ case 5:
buf = qmalloc (len+1);
- else
- Sys_Error ("COM_LoadFile: bad usehunk");
+ break;
+// default:
+// Sys_Error ("COM_LoadFile: bad usehunk");
+// break;
+ }
if (!buf)
Sys_Error ("COM_LoadFile: not enough space for %s", path);
return COM_LoadFile (path, 1, quiet);
}
-byte *COM_LoadTempFile (char *path, qboolean quiet)
-{
- return COM_LoadFile (path, 2, quiet);
-}
-
// LordHavoc: returns malloc'd memory
byte *COM_LoadMallocFile (char *path, qboolean quiet)
{
COM_LoadFile (path, 3, quiet);
}
-// uses temp hunk if larger than bufsize
-byte *COM_LoadStackFile (char *path, void *buffer, int bufsize, qboolean quiet)
-{
- byte *buf;
-
- loadbuf = (byte *)buffer;
- loadsize = bufsize;
- buf = COM_LoadFile (path, 4, quiet);
-
- return buf;
-}
-
/*
=================
COM_LoadPackFile
if (numpackfiles != PAK0_COUNT)
com_modified = true; // not the original file
- newfiles = Hunk_AllocName (numpackfiles * sizeof(packfile_t), "packfile");
+ newfiles = Hunk_AllocName (numpackfiles * sizeof(packfile_t), "pack file-table");
info = qmalloc(sizeof(*info)*MAX_FILES_IN_PACK);
Sys_FileSeek (packhandle, header.dirofs);
}
qfree(info);
- pack = Hunk_Alloc (sizeof (pack_t));
+ pack = Hunk_AllocName (sizeof (pack_t), packfile);
strcpy (pack->filename, packfile);
pack->handle = packhandle;
pack->numfiles = numpackfiles;
//
// add the directory to the search path
//
- search = Hunk_Alloc (sizeof(searchpath_t));
+ search = Hunk_AllocName (sizeof(searchpath_t), "pack info");
strcpy (search->filename, dir);
search->next = com_searchpaths;
com_searchpaths = search;
pak = COM_LoadPackFile (pakfile);
if (!pak)
break;
- search = Hunk_Alloc (sizeof(searchpath_t));
+ search = Hunk_AllocName (sizeof(searchpath_t), "pack info");
search->pack = pak;
search->next = com_searchpaths;
- com_searchpaths = search;
+ com_searchpaths = search;
}
//
//
// -path <dir or packfile> [<dir or packfile>] ...
-// Fully specifies the exact serach path, overriding the generated one
+// Fully specifies the exact search path, overriding the generated one
//
i = COM_CheckParm ("-path");
if (i)
if (!com_argv[i] || com_argv[i][0] == '+' || com_argv[i][0] == '-')
break;
- search = Hunk_Alloc (sizeof(searchpath_t));
+ search = Hunk_AllocName (sizeof(searchpath_t), "pack info");
if ( !strcmp(COM_FileExtension(com_argv[i]), "pak") )
{
search->pack = COM_LoadPackFile (com_argv[i]);
int COM_FOpenFile (char *filename, FILE **file, qboolean quiet);
void COM_CloseFile (int h);
-byte *COM_LoadStackFile (char *path, void *buffer, int bufsize, qboolean quiet);
-byte *COM_LoadTempFile (char *path, qboolean quiet);
byte *COM_LoadHunkFile (char *path, qboolean quiet);
byte *COM_LoadMallocFile (char *path, qboolean quiet);
void COM_LoadCacheFile (char *path, struct cache_user_s *cu, qboolean quiet);
//
// draw texture
//
- poly = Hunk_Alloc (sizeof(glpoly_t) + (lnumverts-4) * VERTEXSIZE*sizeof(float));
+ poly = Hunk_AllocName (sizeof(glpoly_t) + (lnumverts-4) * VERTEXSIZE*sizeof(float), "surfaces");
poly->next = fa->polys;
poly->flags = fa->flags;
fa->polys = poly;
void GL_TextureStats_f(void)
{
- int i, t = 0;
+ int i, s = 0, sc = 0, t = 0;
gltexture_t *glt;
Con_Printf("name kbytes crc mip alpha\n");
for (i = 0, glt = gltextures;i < numgltextures;i++, glt++)
{
GL_TextureStats_Print(glt->identifier, ((glt->totaltexels * 4) + 512) >> 10, glt->crc, glt->mipmap, glt->alpha);
t += glt->totaltexels;
+ if (glt->identifier[0] == '&')
+ {
+ sc++;
+ s += glt->totaltexels;
+ }
}
- Con_Printf("%i textures, totalling %.3f mbytes\n", numgltextures, t / 1024.0 / 1024.0);
+ Con_Printf("%i textures, totalling %.3fMB, %i are (usually) unnecessary model skins totalling %.3fMB\n", numgltextures, t / 1048576.0, sc, s / 1048576.0);
}
void GL_TextureStats_PrintTotal(void)
{
- int i, t = 0;
+ int i, s = 0, sc = 0, t = 0;
gltexture_t *glt;
for (i = 0, glt = gltextures;i < numgltextures;i++, glt++)
+ {
t += glt->totaltexels;
- Con_Printf("%i textures, totalling %.3f mbytes\n", numgltextures, t / 1024.0 / 1024.0);
+ if (glt->identifier[0] == '&')
+ {
+ sc++;
+ s += glt->totaltexels;
+ }
+ }
+ Con_Printf("%i textures, totalling %.3fMB, %i are (usually) unnecessary model skins totalling %.3fMB\n", numgltextures, t / 1048576.0, sc, s / 1048576.0);
}
extern int buildnumber;
return;
}
- poly = Hunk_Alloc (sizeof(glpoly_t) + (numverts-4) * VERTEXSIZE*sizeof(float));
+ poly = Hunk_AllocName (sizeof(glpoly_t) + (numverts-4) * VERTEXSIZE*sizeof(float), "surfaces");
poly->next = warpface->polys;
warpface->polys = poly;
poly->numverts = numverts;
*/
void Host_Init ()
{
-
+ /*
if (standard_quake)
minimum_memory = MINIMUM_MEMORY;
else
if (host_parms.memsize < minimum_memory)
Sys_Error ("Only %4.1f megs of memory available, can't execute game", host_parms.memsize / (float)0x100000);
+ */
com_argc = host_parms.argc;
com_argv = host_parms.argv;
for (i=0 ; i<MAX_LIGHTSTYLES ; i++)
{
fscanf (f, "%s\n", str);
- sv.lightstyles[i] = Hunk_Alloc (strlen(str)+1);
+ sv.lightstyles[i] = Hunk_AllocName (strlen(str)+1, "lightstyles");
strcpy (sv.lightstyles[i], str);
}
sprintf (name, "%s_%i", loadmodel->name, i);
Mod_FloodFillSkin( skin, width, height );
- *skintexnum++ = GL_SkinSplit((byte *)pskintype, skintemp, width, height, 0x3FBD, va("%s_normal", name)); // normal (no special colors)
- *skintexnum++ = GL_SkinSplitShirt((byte *)pskintype, skintemp, width, height, 0x0040, va("%s_pants", name)); // pants
- *skintexnum++ = GL_SkinSplitShirt((byte *)pskintype, skintemp, width, height, 0x0002, va("%s_shirt", name)); // shirt
+ *skintexnum++ = GL_SkinSplit((byte *)pskintype, skintemp, width, height, 0x3FBD, va("&%s_normal", name)); // normal (no special colors)
+ *skintexnum++ = GL_SkinSplitShirt((byte *)pskintype, skintemp, width, height, 0x0040, va("&%s_pants", name)); // pants
+ *skintexnum++ = GL_SkinSplitShirt((byte *)pskintype, skintemp, width, height, 0x0002, va("&%s_shirt", name)); // shirt
*skintexnum++ = GL_SkinSplit((byte *)pskintype, skintemp, width, height, 0xC000, va("%s_glow", name)); // glow
*skintexnum++ = GL_SkinSplit((byte *)pskintype, skintemp, width, height, 0x3FFF, va("%s_body", name)); // body (normal + pants + shirt, but not glow)
pskintype = (daliasskintype_t *)((byte *)(pskintype) + s);
sprintf (name, "%s_%i_%i", loadmodel->name, i,j);
Mod_FloodFillSkin( skin, width, height );
- *skintexnum++ = GL_SkinSplit((byte *)pskintype, skintemp, width, height, 0x3FBD, va("%s_normal", name)); // normal (no special colors)
- *skintexnum++ = GL_SkinSplitShirt((byte *)pskintype, skintemp, width, height, 0x0040, va("%s_pants", name)); // pants
- *skintexnum++ = GL_SkinSplitShirt((byte *)pskintype, skintemp, width, height, 0x0002, va("%s_shirt", name)); // shirt
+ *skintexnum++ = GL_SkinSplit((byte *)pskintype, skintemp, width, height, 0x3FBD, va("&%s_normal", name)); // normal (no special colors)
+ *skintexnum++ = GL_SkinSplitShirt((byte *)pskintype, skintemp, width, height, 0x0040, va("&%s_pants", name)); // pants
+ *skintexnum++ = GL_SkinSplitShirt((byte *)pskintype, skintemp, width, height, 0x0002, va("&%s_shirt", name)); // shirt
*skintexnum++ = GL_SkinSplit((byte *)pskintype, skintemp, width, height, 0xC000, va("%s_glow", name)); // glow
*skintexnum++ = GL_SkinSplit((byte *)pskintype, skintemp, width, height, 0x3FFF, va("%s_body", name)); // body (normal + pants + shirt, but not glow)
pskintype = (daliasskintype_t *)((byte *)(pskintype) + s);
}
// rebuild the model
- mheader = Hunk_AllocName (sizeof(maliashdr_t), loadname);
+ mheader = Hunk_AllocName (sizeof(maliashdr_t), va("%s model header", loadname));
mod->flags = LittleLong (pinmodel->flags);
mod->type = mod_alias;
// endian-adjust and copy the data, starting with the alias model header
}
// load triangle data
- pouttris = Hunk_AllocName(sizeof(unsigned short[3]) * numtris, loadname);
+ pouttris = Hunk_AllocName(sizeof(unsigned short[3]) * numtris, va("%s triangles", loadname));
mheader->tridata = (int) pouttris - (int) mheader;
pintriangles = (dtriangle_t *)&pinstverts[mheader->numverts];
*pouttris++ = vertremap[temptris[i][2]];
}
// store the texture coordinates
- pouttexcoords = Hunk_AllocName(sizeof(float[2]) * totalverts, loadname);
+ pouttexcoords = Hunk_AllocName(sizeof(float[2]) * totalverts, va("%s texcoords", loadname));
mheader->texdata = (int) pouttexcoords - (int) mheader;
for (i = 0;i < totalverts;i++)
{
// load the frames
posenum = 0;
- frame = Hunk_AllocName(sizeof(maliasframe_t) * numframes, loadname);
+ frame = Hunk_AllocName(sizeof(maliasframe_t) * numframes, va("%s frame info", loadname));
mheader->framedata = (int) frame - (int) mheader;
- posevert = Hunk_AllocName(sizeof(trivert2) * numposes * totalverts, loadname);
+ posevert = Hunk_AllocName(sizeof(trivert2) * numposes * totalverts, va("%s vertex data", loadname));
mheader->posedata = (int) posevert - (int) mheader;
pframetype = (daliasframetype_t *)&pintriangles[numtris];
+ LittleLong(pinmodel->num_glcmds) * sizeof(int);
if (size <= 0 || size >= MD2MAX_SIZE)
Host_Error ("%s is not a valid model", mod->name);
- pheader = Hunk_AllocName (size, loadname);
+ pheader = Hunk_AllocName (size, va("%s Quake2 model", loadname));
mod->flags = 0; // there are no MD2 flags
mod->numframes = LittleLong(pinmodel->num_frames);
m->nummiptex = LittleLong (m->nummiptex);
loadmodel->numtextures = m->nummiptex;
- loadmodel->textures = Hunk_AllocName (m->nummiptex * sizeof(*loadmodel->textures) , loadname);
+ loadmodel->textures = Hunk_AllocName (m->nummiptex * sizeof(*loadmodel->textures), va("%s texture headers", loadname));
// just to work around bounds checking when debugging with it (array index out of bounds error thing)
dofs = m->dataofs;
if ( (mt->width & 15) || (mt->height & 15) )
Host_Error ("Texture %s is not 16 aligned", mt->name);
// LordHavoc: rewriting the map texture loader for GLQuake
- tx = Hunk_AllocName (sizeof(texture_t), loadname );
+ tx = Hunk_AllocName (sizeof(texture_t), va("%s textures", loadname));
loadmodel->textures[i] = tx;
// LordHavoc: force all names to lowercase and make sure they are terminated while copying
loadmodel->lightdata = NULL;
if (hlbsp) // LordHavoc: load the colored lighting data straight
{
- loadmodel->lightdata = Hunk_AllocName ( l->filelen, loadname);
+ loadmodel->lightdata = Hunk_AllocName ( l->filelen, va("%s lightmaps", loadname));
memcpy (loadmodel->lightdata, mod_base + l->fileofs, l->filelen);
}
else // LordHavoc: bsp version 29 (normal white lighting)
// LordHavoc: oh well, expand the white lighting data
if (!l->filelen)
return;
- loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, litfilename);
+ loadmodel->lightdata = Hunk_AllocName ( l->filelen*3, va("%s lightmaps", loadname));
in = loadmodel->lightdata + l->filelen*2; // place the file at the end, so it will not be overwritten until the very last write
out = loadmodel->lightdata;
memcpy (in, mod_base + l->fileofs, l->filelen);
loadmodel->visdata = NULL;
return;
}
- loadmodel->visdata = Hunk_AllocName ( l->filelen, loadname);
+ loadmodel->visdata = Hunk_AllocName ( l->filelen, va("%s visdata", loadname));
memcpy (loadmodel->visdata, mod_base + l->fileofs, l->filelen);
}
loadmodel->entities = NULL;
return;
}
- loadmodel->entities = Hunk_AllocName ( l->filelen, loadname);
+ loadmodel->entities = Hunk_AllocName ( l->filelen, va("%s entities", loadname));
memcpy (loadmodel->entities, mod_base + l->fileofs, l->filelen);
if (isworldmodel)
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s vertices", loadname));
loadmodel->vertexes = out;
loadmodel->numvertexes = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s submodels", loadname));
loadmodel->submodels = out;
loadmodel->numsubmodels = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( (count + 1) * sizeof(*out), loadname);
+ out = Hunk_AllocName ( (count + 1) * sizeof(*out), va("%s edges", loadname));
loadmodel->edges = out;
loadmodel->numedges = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s texinfo", loadname));
loadmodel->texinfo = out;
loadmodel->numtexinfo = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s faces", loadname));
loadmodel->surfaces = out;
loadmodel->numsurfaces = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s nodes", loadname));
loadmodel->nodes = out;
loadmodel->numnodes = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s leafs", loadname));
loadmodel->leafs = out;
loadmodel->numleafs = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s clipnodes", loadname));
loadmodel->clipnodes = out;
loadmodel->numclipnodes = count;
in = loadmodel->nodes;
count = loadmodel->numnodes;
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s hull0", loadname));
hull->clipnodes = out;
hull->firstclipnode = 0;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s marksurfaces", loadname));
loadmodel->marksurfaces = out;
loadmodel->nummarksurfaces = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*sizeof(*out), va("%s surfedges", loadname));
loadmodel->surfedges = out;
loadmodel->numsurfedges = count;
if (l->filelen % sizeof(*in))
Host_Error ("MOD_LoadBmodel: funny lump size in %s",loadmodel->name);
count = l->filelen / sizeof(*in);
- out = Hunk_AllocName ( count*2*sizeof(*out), loadname);
+ out = Hunk_AllocName ( count*2*sizeof(*out), va("%s planes", loadname));
loadmodel->planes = out;
loadmodel->numplanes = count;
height = LittleLong (pinframe->height);
size = width * height * bytesperpixel;
- pspriteframe = Hunk_AllocName (sizeof (mspriteframe_t),loadname);
+ pspriteframe = Hunk_AllocName (sizeof (mspriteframe_t), va("%s frames", loadname));
memset (pspriteframe, 0, sizeof (mspriteframe_t));
numframes = LittleLong (pingroup->numframes);
- pspritegroup = Hunk_AllocName (sizeof (mspritegroup_t) +
- (numframes - 1) * sizeof (pspritegroup->frames[0]), loadname);
+ pspritegroup = Hunk_AllocName (sizeof (mspritegroup_t) + (numframes - 1) * sizeof (pspritegroup->frames[0]), va("%s frames", loadname));
pspritegroup->numframes = numframes;
pin_intervals = (dspriteinterval_t *)(pingroup + 1);
- poutintervals = Hunk_AllocName (numframes * sizeof (float), loadname);
+ poutintervals = Hunk_AllocName (numframes * sizeof (float), va("%s frames", loadname));
pspritegroup->intervals = poutintervals;
size = sizeof (msprite_t) + (numframes - 1) * sizeof (psprite->frames);
- psprite = Hunk_AllocName (size, loadname);
+ psprite = Hunk_AllocName (size, va("%s info", loadname));
mod->cache.data = psprite;
int i,l;
l = strlen(string) + 1;
- new = Hunk_Alloc (l);
+ new = Hunk_AllocName (l, "edict string");
new_p = new;
for (i=0 ; i< l ; i++)
#define UNUSED(x) (x = x) // for pesky compiler / lint warnings
-#define MINIMUM_MEMORY 0x550000
-#define MINIMUM_MEMORY_LEVELPAK (MINIMUM_MEMORY + 0x100000)
+// LordHavoc: default heap size (unless -heapsize (win32 only) or -mem is used), in megabytes
+#define DEFAULTMEM 24
+//#define MINIMUM_MEMORY 0x550000
+//#define MINIMUM_MEMORY_LEVELPAK (MINIMUM_MEMORY + 0x100000)
#define MAX_NUM_ARGVS 50
host_parms.argc = com_argc;
host_parms.argv = com_argv;
- host_parms.memsize = 24*1024*1024;
+ host_parms.memsize = DEFAULTMEM * 1024*1024;
j = COM_CheckParm("-mem");
if (j)
#include "conproc.h"
#include "direct.h"
-// LordHavoc: raised min to 64mb (was 8.5mb)
-#define MINIMUM_WIN_MEMORY 0x04000000
-// LordHavoc: raised max to 64mb (was 16mb)
-#define MAXIMUM_WIN_MEMORY 0x04000000
-
#define CONSOLE_ERROR_TIMEOUT 60.0 // # of seconds to wait on Sys_Error running
// dedicated before exiting
#define PAUSE_SLEEP 50 // sleep time on pause or minimization
// take the greater of all the available memory or half the total memory,
// but at least 8 Mb and no more than 16 Mb, unless they explicitly
// request otherwise
+ /*
host_parms.memsize = lpBuffer.dwAvailPhys;
if (host_parms.memsize < MINIMUM_WIN_MEMORY)
if (host_parms.memsize > MAXIMUM_WIN_MEMORY)
host_parms.memsize = MAXIMUM_WIN_MEMORY;
+ */
+ host_parms.memsize = DEFAULTMEM * 1048576;
if ((t = COM_CheckParm("-heapsize")))
{
memset (&host_parms, 0, sizeof(host_parms));
- host_parms.memsize = 16384*1024;
+ host_parms.memsize = DEFAULTMEM * 1024*1024;
host_parms.membase = qmalloc(parms.memsize);
_getcwd (cwd, sizeof(cwd));
{
int sentinal;
int size; // including sizeof(hunk_t), -1 = not allocated
- char name[8];
+ char name[24];
} hunk_t;
byte *hunk_base;
int hunk_low_used;
int hunk_high_used;
-qboolean hunk_tempactive;
-int hunk_tempmark;
-
void R_FreeTextures (void);
/*
==============
Hunk_Check
-Run consistancy and sentinal trahing checks
+Run consistancy and sentinal trashing checks
==============
*/
void Hunk_Check (void)
for (h = (hunk_t *)hunk_base ; (byte *)h != hunk_base + hunk_low_used ; )
{
if (h->sentinal != HUNK_SENTINAL)
- Sys_Error ("Hunk_Check: trahsed sentinal");
- if (h->size < 16 || h->size + (byte *)h - hunk_base > hunk_size)
+ Sys_Error ("Hunk_Check: trashed sentinal");
+ if (h->size < sizeof(hunk_t) || h->size + (byte *)h - hunk_base > hunk_size)
Sys_Error ("Hunk_Check: bad size");
h = (hunk_t *)((byte *)h+h->size);
}
void Hunk_Print (qboolean all)
{
hunk_t *h, *next, *endlow, *starthigh, *endhigh;
- int count, sum;
+ int count, sum, i;
int totalblocks;
- char name[9];
+ char name[25];
- name[8] = 0;
+ name[24] = 0;
count = 0;
sum = 0;
totalblocks = 0;
starthigh = (hunk_t *)(hunk_base + hunk_size - hunk_high_used);
endhigh = (hunk_t *)(hunk_base + hunk_size);
- Con_Printf (" :%8i total hunk size\n", hunk_size);
+ Con_Printf (" :%8i total hunk size\n", hunk_size);
Con_Printf ("-------------------------\n");
while (1)
//
if (h->sentinal != HUNK_SENTINAL)
Sys_Error ("Hunk_Check: trashed sentinal");
- if (h->size < 16 || h->size + (byte *)h - hunk_base > hunk_size)
+ if (h->size < sizeof(hunk_t) || h->size + (byte *)h - hunk_base > hunk_size)
Sys_Error ("Hunk_Check: bad size");
next = (hunk_t *)((byte *)h+h->size);
//
// print the single block
//
- memcpy (name, h->name, 8);
+ // LordHavoc: pad name to full length
+ for (i = 0;i < 24;i++)
+ {
+ if (!h->name[i])
+ break;
+ name[i] = h->name[i];
+ }
+ for (;i < 24;i++)
+ name[i] = ' ';
+ //memcpy (name, h->name, 24);
if (all)
- Con_Printf ("%8p :%8i %8s\n",h, h->size, name);
+ Con_Printf ("%8p :%8i %s\n",h, h->size, name);
//
// print the total
//
- if (next == endlow || next == endhigh ||
- strncmp (h->name, next->name, 8) )
+ if (next == endlow || next == endhigh || strncmp(h->name, next->name, 24))
{
if (!all)
- Con_Printf (" :%8i %8s (TOTAL)\n",sum, name);
+ Con_Printf (" :%8i %s (TOTAL)\n",sum, name);
count = 0;
sum = 0;
}
h = next;
}
- Con_Printf ("-------------------------\n");
+// Con_Printf ("-------------------------\n");
Con_Printf ("%8i total blocks\n", totalblocks);
}
h->size = size;
h->sentinal = HUNK_SENTINAL;
- strncpy (h->name, name, 8);
+ strncpy (h->name, name, 24);
return (void *)(h+1);
}
-/*
-===================
-Hunk_Alloc
-===================
-*/
-void *Hunk_Alloc (int size)
-{
- return Hunk_AllocName (size, "unknown");
-}
-
int Hunk_LowMark (void)
{
return hunk_low_used;
int Hunk_HighMark (void)
{
- if (hunk_tempactive)
- {
- hunk_tempactive = false;
- Hunk_FreeToHighMark (hunk_tempmark);
- }
-
return hunk_high_used;
}
void Hunk_FreeToHighMark (int mark)
{
- if (hunk_tempactive)
- {
- hunk_tempactive = false;
- Hunk_FreeToHighMark (hunk_tempmark);
- }
if (mark < 0 || mark > hunk_high_used)
Sys_Error ("Hunk_FreeToHighMark: bad mark %i", mark);
memset (hunk_base + hunk_size - hunk_high_used, 0, hunk_high_used - mark);
if (size < 0)
Sys_Error ("Hunk_HighAllocName: bad size: %i", size);
- if (hunk_tempactive)
- {
- Hunk_FreeToHighMark (hunk_tempmark);
- hunk_tempactive = false;
- }
-
#ifdef PARANOID
Hunk_Check ();
#endif
return (void *)(h+1);
}
-
-/*
-=================
-Hunk_TempAlloc
-
-Return space from the top of the hunk
-=================
-*/
-void *Hunk_TempAlloc (int size)
-{
- void *buf;
-
- size = (size+15)&~15;
-
- if (hunk_tempactive)
- {
- Hunk_FreeToHighMark (hunk_tempmark);
- hunk_tempactive = false;
- }
-
- hunk_tempmark = Hunk_HighMark ();
-
- buf = Hunk_HighAllocName (size, "temp");
-
- hunk_tempactive = true;
-
- return buf;
-}
-
/*
===============================================================================
void Z_CheckHeap (void);
int Z_FreeMemory (void);
-void *Hunk_Alloc (int size); // returns 0 filled memory
void *Hunk_AllocName (int size, char *name);
void *Hunk_HighAllocName (int size, char *name);
int Hunk_HighMark (void);
void Hunk_FreeToHighMark (int mark);
-void *Hunk_TempAlloc (int size);
-
void Hunk_Check (void);
typedef struct cache_user_s