From 400e4a34bbef54082e7d39758fa5aa7ab1b654c7 Mon Sep 17 00:00:00 2001 From: lordhavoc Date: Mon, 29 Jan 2001 11:59:51 +0000 Subject: [PATCH] got rid of Hunk_Alloc, all allocations now have a proper name (perhaps a bit too descriptive even), improved texture tally to list wasted skin layers (colormapping), made hunk names 24 characters instead of 8. git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@142 d7cf8633-e32d-0410-b094-e92efae38249 --- cmd.c | 2 +- common.c | 64 ++++++++++++-------------------- common.h | 2 - gl_rsurf.c | 2 +- gl_textures.c | 20 ++++++++-- gl_warp.c | 2 +- host.c | 3 +- host_cmd.c | 2 +- model_alias.c | 24 ++++++------ model_brush.c | 36 +++++++++--------- model_sprite.c | 9 ++--- pr_edict.c | 2 +- quakedef.h | 6 ++- sys_linux.c | 2 +- sys_win.c | 8 ++-- sys_wind.c | 2 +- zone.c | 99 ++++++++++++-------------------------------------- zone.h | 3 -- 18 files changed, 113 insertions(+), 175 deletions(-) diff --git a/cmd.c b/cmd.c index bf4579b8..6bb726f4 100644 --- a/cmd.c +++ b/cmd.c @@ -553,7 +553,7 @@ void Cmd_AddCommand (char *cmd_name, xcommand_t function) } } - 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; diff --git a/common.c b/common.c index bd8d2f8b..a3baf195 100644 --- a/common.c +++ b/common.c @@ -1634,25 +1634,24 @@ byte *COM_LoadFile (char *path, int usehunk, qboolean quiet) // 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); @@ -1670,11 +1669,6 @@ byte *COM_LoadHunkFile (char *path, qboolean quiet) 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) { @@ -1687,18 +1681,6 @@ void COM_LoadCacheFile (char *path, struct cache_user_s *cu, 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 @@ -1741,7 +1723,7 @@ pack_t *COM_LoadPackFile (char *packfile) 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); @@ -1765,7 +1747,7 @@ pack_t *COM_LoadPackFile (char *packfile) } 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; @@ -1796,7 +1778,7 @@ void COM_AddGameDirectory (char *dir) // // 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; @@ -1810,10 +1792,10 @@ void COM_AddGameDirectory (char *dir) 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; } // @@ -1898,7 +1880,7 @@ void COM_InitFilesystem (void) // // -path [] ... -// 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) @@ -1910,7 +1892,7 @@ void COM_InitFilesystem (void) 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]); diff --git a/common.h b/common.h index 051b2acd..ad55254f 100644 --- a/common.h +++ b/common.h @@ -201,8 +201,6 @@ int COM_OpenFile (char *filename, int *hndl, qboolean quiet); 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); diff --git a/gl_rsurf.c b/gl_rsurf.c index 4377edc7..753f5db2 100644 --- a/gl_rsurf.c +++ b/gl_rsurf.c @@ -1142,7 +1142,7 @@ void BuildSurfaceDisplayList (msurface_t *fa) // // 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; diff --git a/gl_textures.c b/gl_textures.c index 952ea1f8..e2b6aeaa 100644 --- a/gl_textures.c +++ b/gl_textures.c @@ -115,24 +115,36 @@ void GL_TextureStats_Print(char *name, int total, int crc, int mip, int alpha) 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; diff --git a/gl_warp.c b/gl_warp.c index 495f5939..296da186 100644 --- a/gl_warp.c +++ b/gl_warp.c @@ -120,7 +120,7 @@ void SubdividePolygon (int numverts, float *verts) 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; diff --git a/host.c b/host.c index f9dc58d5..8ca544a4 100644 --- a/host.c +++ b/host.c @@ -798,7 +798,7 @@ Host_Init */ void Host_Init () { - + /* if (standard_quake) minimum_memory = MINIMUM_MEMORY; else @@ -809,6 +809,7 @@ void Host_Init () 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; diff --git a/host_cmd.c b/host_cmd.c index 44701986..5051ed0e 100644 --- a/host_cmd.c +++ b/host_cmd.c @@ -595,7 +595,7 @@ void Host_Loadgame_f (void) for (i=0 ; iname, 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); @@ -363,9 +363,9 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int width, in 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); @@ -463,7 +463,7 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer) } // 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 @@ -503,7 +503,7 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer) } // 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]; @@ -548,7 +548,7 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer) *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++) { @@ -558,9 +558,9 @@ void Mod_LoadAliasModel (model_t *mod, void *buffer) // 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]; @@ -712,7 +712,7 @@ void Mod_LoadQ2AliasModel (model_t *mod, void *buffer) + 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); diff --git a/model_brush.c b/model_brush.c index c070d421..0efc4e70 100644 --- a/model_brush.c +++ b/model_brush.c @@ -124,7 +124,7 @@ void Mod_LoadTextures (lump_t *l) 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; @@ -142,7 +142,7 @@ void Mod_LoadTextures (lump_t *l) 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 @@ -335,7 +335,7 @@ void Mod_LoadLighting (lump_t *l) 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) @@ -365,7 +365,7 @@ void Mod_LoadLighting (lump_t *l) // 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); @@ -392,7 +392,7 @@ void Mod_LoadVisibility (lump_t *l) 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); } @@ -412,7 +412,7 @@ void Mod_LoadEntities (lump_t *l) 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) @@ -435,7 +435,7 @@ void Mod_LoadVertexes (lump_t *l) 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; @@ -463,7 +463,7 @@ void Mod_LoadSubmodels (lump_t *l) 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; @@ -499,7 +499,7 @@ void Mod_LoadEdges (lump_t *l) 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; @@ -528,7 +528,7 @@ void Mod_LoadTexinfo (lump_t *l) 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; @@ -653,7 +653,7 @@ void Mod_LoadFaces (lump_t *l) 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; @@ -752,7 +752,7 @@ void Mod_LoadNodes (lump_t *l) 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; @@ -799,7 +799,7 @@ void Mod_LoadLeafs (lump_t *l) 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; @@ -856,7 +856,7 @@ void Mod_LoadClipnodes (lump_t *l) 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; @@ -954,7 +954,7 @@ void Mod_MakeHull0 (void) 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; @@ -990,7 +990,7 @@ void Mod_LoadMarksurfaces (lump_t *l) 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; @@ -1018,7 +1018,7 @@ void Mod_LoadSurfedges (lump_t *l) 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; @@ -1045,7 +1045,7 @@ void Mod_LoadPlanes (lump_t *l) 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; diff --git a/model_sprite.c b/model_sprite.c index c1d63e52..4db67bca 100644 --- a/model_sprite.c +++ b/model_sprite.c @@ -67,7 +67,7 @@ void * Mod_LoadSpriteFrame (void * pin, mspriteframe_t **ppframe, int framenum, 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)); @@ -145,8 +145,7 @@ void * Mod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int framenum, 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; @@ -154,7 +153,7 @@ void * Mod_LoadSpriteGroup (void * pin, mspriteframe_t **ppframe, int framenum, 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; @@ -225,7 +224,7 @@ void Mod_LoadSpriteModel (model_t *mod, void *buffer) 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; diff --git a/pr_edict.c b/pr_edict.c index 7f2bcf08..f816537d 100644 --- a/pr_edict.c +++ b/pr_edict.c @@ -807,7 +807,7 @@ char *ED_NewString (char *string) 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++) diff --git a/quakedef.h b/quakedef.h index 899886de..7f274b77 100644 --- a/quakedef.h +++ b/quakedef.h @@ -46,8 +46,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #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 diff --git a/sys_linux.c b/sys_linux.c index 8095fa9b..fd1e5365 100644 --- a/sys_linux.c +++ b/sys_linux.c @@ -411,7 +411,7 @@ int main (int c, char **v) 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) diff --git a/sys_win.c b/sys_win.c index 57492626..bf7d54a1 100644 --- a/sys_win.c +++ b/sys_win.c @@ -26,11 +26,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #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 @@ -694,6 +689,7 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin // 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) @@ -704,6 +700,8 @@ int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLin if (host_parms.memsize > MAXIMUM_WIN_MEMORY) host_parms.memsize = MAXIMUM_WIN_MEMORY; + */ + host_parms.memsize = DEFAULTMEM * 1048576; if ((t = COM_CheckParm("-heapsize"))) { diff --git a/sys_wind.c b/sys_wind.c index 6703846f..594b9255 100644 --- a/sys_wind.c +++ b/sys_wind.c @@ -268,7 +268,7 @@ int main (int argc, char **argv) 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)); diff --git a/zone.c b/zone.c index 7548ae00..3549f700 100644 --- a/zone.c +++ b/zone.c @@ -271,7 +271,7 @@ typedef struct { int sentinal; int size; // including sizeof(hunk_t), -1 = not allocated - char name[8]; + char name[24]; } hunk_t; byte *hunk_base; @@ -280,16 +280,13 @@ int hunk_size; 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) @@ -299,8 +296,8 @@ 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); } @@ -317,11 +314,11 @@ Otherwise, allocations with the same name will be totaled up before printing. 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; @@ -331,7 +328,7 @@ void Hunk_Print (qboolean all) 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) @@ -358,7 +355,7 @@ void Hunk_Print (qboolean all) // 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); @@ -369,18 +366,26 @@ void Hunk_Print (qboolean all) // // 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; } @@ -388,7 +393,7 @@ void Hunk_Print (qboolean all) h = next; } - Con_Printf ("-------------------------\n"); +// Con_Printf ("-------------------------\n"); Con_Printf ("%8i total blocks\n", totalblocks); } @@ -423,21 +428,11 @@ void *Hunk_AllocName (int size, char *name) 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; @@ -453,22 +448,11 @@ void Hunk_FreeToLowMark (int mark) 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); @@ -488,12 +472,6 @@ void *Hunk_HighAllocName (int size, char *name) 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 @@ -519,35 +497,6 @@ void *Hunk_HighAllocName (int size, char *name) 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; -} - /* =============================================================================== diff --git a/zone.h b/zone.h index 7655ad9c..6ec7efca 100644 --- a/zone.h +++ b/zone.h @@ -93,7 +93,6 @@ void Z_DumpHeap (void); 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); @@ -104,8 +103,6 @@ void Hunk_FreeToLowMark (int mark); int Hunk_HighMark (void); void Hunk_FreeToHighMark (int mark); -void *Hunk_TempAlloc (int size); - void Hunk_Check (void); typedef struct cache_user_s -- 2.39.2