]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
got rid of Hunk_Alloc, all allocations now have a proper name (perhaps a bit too...
authorlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 29 Jan 2001 11:59:51 +0000 (11:59 +0000)
committerlordhavoc <lordhavoc@d7cf8633-e32d-0410-b094-e92efae38249>
Mon, 29 Jan 2001 11:59:51 +0000 (11:59 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@142 d7cf8633-e32d-0410-b094-e92efae38249

18 files changed:
cmd.c
common.c
common.h
gl_rsurf.c
gl_textures.c
gl_warp.c
host.c
host_cmd.c
model_alias.c
model_brush.c
model_sprite.c
pr_edict.c
quakedef.h
sys_linux.c
sys_win.c
sys_wind.c
zone.c
zone.h

diff --git a/cmd.c b/cmd.c
index bf4579b85401c29cc3188b805d43729e2e71ae51..6bb726f458f9e8b711435dd717c18fa23906dcd6 100644 (file)
--- 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;
index bd8d2f8b4d7f1cd4ba7efcb0152ffe4b433c09b2..a3baf1955ff57267f42001e484eb5fde28ea5841 100644 (file)
--- 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 <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)
@@ -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]);
index 051b2acda0d64bd48a16908712d15d865fc2d5e7..ad55254f6560dbfc2fe474c45209ad7637042c99 100644 (file)
--- 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);
index 4377edc717e039979a0205f839d5510e5d554ccf..753f5db276b7a6deadd8a0c8e87465d53c2ecca7 100644 (file)
@@ -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;
index 952ea1f881c4deaf802281b4a961844eb8714b4b..e2b6aeaad7a9e8f72bde976a4a41aaf04d79ba63 100644 (file)
@@ -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;
index 495f59399f60506883b04e27bde5e1c19431b17f..296da1860d0a5fedd04f27543cb2ebde77730cf6 100644 (file)
--- 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 f9dc58d55545ca586581ed347fbdb19295dfac12..8ca544a437d354c33660c6ed7a17f2d6a3a7cb2b 100644 (file)
--- 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;
index 44701986a659c7a5fd94e23d82dcf8e345c5ea07..5051ed0e0e31cc3b7410b371ff5657ac9a23d060 100644 (file)
@@ -595,7 +595,7 @@ void Host_Loadgame_f (void)
        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);
        }
 
index c6b72f66584fc8f83e09e2562af304459003d4b3..d3cb6e782e0f8eddb5b2103401a0a8b32fb6853b 100644 (file)
@@ -340,9 +340,9 @@ void *Mod_LoadAllSkins (int numskins, daliasskintype_t *pskintype, int width, in
                        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);
@@ -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);
index c070d4217a4126a3a554c47beb82b4d5f0984ac8..0efc4e70c62b2d9476a2bd25df8f43d5e506d839 100644 (file)
@@ -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;
index c1d63e523c07aef8b832bd2bd10659326b39bc52..4db67bca50b0eb800e967a02f7bfb6b74f5e6ad9 100644 (file)
@@ -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;
 
index 7f2bcf08d4bcfa420f55c893392d7e94ef503de6..f816537dd3660462c450aab3907a3655ff8baf34 100644 (file)
@@ -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++)
index 899886de0ef01cf5f590c0b797c43ed3b79a3697..7f274b7793ddb5c27be707eeaeaadac6d4f67983 100644 (file)
@@ -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
 
index 8095fa9bb4bafa1af5d198db2ea64daae15456fd..fd1e53653674b7ffa41b24dcf52997a5cb09232f 100644 (file)
@@ -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)
index 574926260bc87247ccbab7611e68f4cd52376590..bf7d54a16dc561a838041535106cf135e937fa2f 100644 (file)
--- 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")))
        {
index 6703846f8276a168341f8159b7052af050c61e38..594b9255039c943fcefc445c6c47a2b246b15f7e 100644 (file)
@@ -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 7548ae006a3e6f1bca440f98204409bc31ad8ecc..3549f7001f709849f98f6c01b8b09d27a35d6055 100644 (file)
--- 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 7655ad9c083284c12a9c6ced62b076625d5600eb..6ec7efca18ab9abf80a5d16ae78f7e0e48b6a5c6 100644 (file)
--- 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