]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Added a mempool parameter to FS_LoadFile
authormolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 23 Mar 2004 07:59:09 +0000 (07:59 +0000)
committermolivier <molivier@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 23 Mar 2004 07:59:09 +0000 (07:59 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@4051 d7cf8633-e32d-0410-b094-e92efae38249

18 files changed:
cl_particles.c
cmd.c
fs.c
fs.h
gl_rmain.c
image.c
menu.c
model_brush.c
model_shared.c
palette.c
pr_edict.c
prvm_cmds.c
prvm_edict.c
r_shadow.c
snd_mem.c
snd_ogg.c
sv_main.c
wad.c

index 1a6ae07dcd3f8fe63e11823a424cb796c361f1b4..790abe05826c89efc035c87814271b1fde9f032f 100644 (file)
@@ -542,7 +542,7 @@ void CL_ReadPointFile_f (void)
 #if WORKINGLQUAKE
        pointfile = COM_LoadTempFile (name);
 #else
-       pointfile = FS_LoadFile(name, true);
+       pointfile = FS_LoadFile(name, tempmempool, true);
 #endif
        if (!pointfile)
        {
diff --git a/cmd.c b/cmd.c
index ec5e3cb5197a72e0d1a12fe02e22acedcab808b6..acba1396069493e161ac993c16e460446ae56ff0 100644 (file)
--- a/cmd.c
+++ b/cmd.c
@@ -294,7 +294,7 @@ static void Cmd_Exec_f (void)
                return;
        }
 
-       f = (char *)FS_LoadFile (Cmd_Argv(1), false);
+       f = (char *)FS_LoadFile (Cmd_Argv(1), tempmempool, false);
        if (!f)
        {
                Con_Printf("couldn't exec %s\n",Cmd_Argv(1));
diff --git a/fs.c b/fs.c
index cebf3e4c2b3013d69e30e1d7f78715800eddb84b..093d0ac9ad3a7cec37d5bd7d803d6d9efaf3e164 100644 (file)
--- a/fs.c
+++ b/fs.c
@@ -1719,7 +1719,7 @@ Filename are relative to the quake directory.
 Always appends a 0 byte.
 ============
 */
-qbyte *FS_LoadFile (const char *path, qboolean quiet)
+qbyte *FS_LoadFile (const char *path, mempool_t *pool, qboolean quiet)
 {
        qfile_t *h;
        qbyte *buf;
@@ -1729,7 +1729,7 @@ qbyte *FS_LoadFile (const char *path, qboolean quiet)
        if (!h)
                return NULL;
 
-       buf = Mem_Alloc(tempmempool, fs_filesize+1);
+       buf = Mem_Alloc(pool, fs_filesize+1);
        if (!buf)
                Sys_Error ("FS_LoadFile: not enough available memory for %s (size %i)", path, fs_filesize);
 
diff --git a/fs.h b/fs.h
index da3b6a006b8f42f837e63f6c30a8170dcfe04ba6..228b75b6ac137a54dd4727ae70577a20c5d076b5 100644 (file)
--- a/fs.h
+++ b/fs.h
@@ -70,7 +70,7 @@ fssearch_t;
 fssearch_t *FS_Search(const char *pattern, int caseinsensitive, int quiet);
 void FS_FreeSearch(fssearch_t *search);
 
-qbyte *FS_LoadFile (const char *path, qboolean quiet);
+qbyte *FS_LoadFile (const char *path, mempool_t *pool, qboolean quiet);
 qboolean FS_WriteFile (const char *filename, void *data, int len);
 
 
index bcaf390d9cb26e1260c40a0edb2b9a2a7902e3dd..76123a6f450eaef7107c413eba6259f4a22fc77f 100644 (file)
@@ -239,7 +239,7 @@ void gl_main_newmap(void)
                if (l >= 0 && !strcmp(entname + l, ".bsp"))
                {
                        strcpy(entname + l, ".ent");
-                       if ((entities = FS_LoadFile(entname, true)))
+                       if ((entities = FS_LoadFile(entname, tempmempool, true)))
                        {
                                CL_ParseEntityLump(entities);
                                Mem_Free(entities);
diff --git a/image.c b/image.c
index 4dae89a9a9880087a2ba99ac06c45205b70c3b8a..2d3882c9c0cb44c6a17012779df67140aef5b8ba 100644 (file)
--- a/image.c
+++ b/image.c
@@ -655,7 +655,7 @@ qbyte *loadimagepixels (const char *filename, qboolean complain, int matchwidth,
        for (i = 0;imageformats[i].formatstring;i++)
        {
                sprintf (name, imageformats[i].formatstring, basename);
-               f = FS_LoadFile(name, true);
+               f = FS_LoadFile(name, tempmempool, true);
                if (f)
                {
                        data = imageformats[i].loadfunc(f, matchwidth, matchheight);
diff --git a/menu.c b/menu.c
index 180fb1352b43dd0371b3481a6ed8aad7fb384ba3..c486bcb6fcb600afdcf34cdff8eb767942b48cdd 100644 (file)
--- a/menu.c
+++ b/menu.c
@@ -991,7 +991,7 @@ void M_Setup_Draw (void)
                menuplyr_load = false;
                menuplyr_top = -1;
                menuplyr_bottom = -1;
-               if ((f = FS_LoadFile("gfx/menuplyr.lmp", true)))
+               if ((f = FS_LoadFile("gfx/menuplyr.lmp", tempmempool, true)))
                {
                        data = LoadLMPAs8Bit (f, 0, 0);
                        menuplyr_width = image_width;
index 28714ec91734554ddabd7119f2b360e566b85eb9..40c3dc94f9acea845eff5bf5da3900ddd866fcfb 100644 (file)
@@ -1209,7 +1209,7 @@ static void Mod_Q1BSP_LoadLighting(lump_t *l)
                strlcpy (litfilename, loadmodel->name, sizeof (litfilename));
                FS_StripExtension (litfilename, litfilename, sizeof (litfilename));
                strlcat (litfilename, ".lit", sizeof (litfilename));
-               data = (qbyte*) FS_LoadFile(litfilename, false);
+               data = (qbyte*) FS_LoadFile(litfilename, tempmempool, false);
                if (data)
                {
                        if (fs_filesize > 8 && data[0] == 'Q' && data[1] == 'L' && data[2] == 'I' && data[3] == 'T')
@@ -1264,7 +1264,7 @@ static void Mod_Q1BSP_LoadLightList(void)
        strlcpy (lightsfilename, loadmodel->name, sizeof (lightsfilename));
        FS_StripExtension (lightsfilename, lightsfilename, sizeof(lightsfilename));
        strlcat (lightsfilename, ".lights", sizeof (lightsfilename));
-       s = lightsstring = (char *) FS_LoadFile(lightsfilename, false);
+       s = lightsstring = (char *) FS_LoadFile(lightsfilename, tempmempool, false);
        if (s)
        {
                numlights = 0;
@@ -3592,7 +3592,7 @@ static void Mod_Q3BSP_LoadTextures(lump_t *l)
        {
                for (i = 0;i < search->numfilenames;i++)
                {
-                       if ((f = FS_LoadFile(search->filenames[i], false)))
+                       if ((f = FS_LoadFile(search->filenames[i], tempmempool, false)))
                        {
                                text = f;
                                while (COM_ParseToken(&text, false))
index 634c799f1936d8caa7e97ad700101ff5a2a87d3b..3927458428f3d40517c3b49754e77a353f679132 100644 (file)
@@ -264,7 +264,7 @@ static model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk,
        {
                if (checkdisk)
                {
-                       buf = FS_LoadFile (mod->name, false);
+                       buf = FS_LoadFile (mod->name, tempmempool, false);
                        if (!buf)
                        {
                                if (crash)
@@ -289,7 +289,7 @@ static model_t *Mod_LoadModel(model_t *mod, qboolean crash, qboolean checkdisk,
 
        if (!buf)
        {
-               buf = FS_LoadFile (mod->name, false);
+               buf = FS_LoadFile (mod->name, tempmempool, false);
                if (!buf)
                {
                        if (crash)
@@ -1107,7 +1107,7 @@ tag_torso,
 */
        memset(tagsets, 0, sizeof(tagsets));
        memset(word, 0, sizeof(word));
-       for (i = 0;i < MAX_SKINS && (data = text = FS_LoadFile(va("%s_%i.skin", loadmodel->name, i), true));i++)
+       for (i = 0;i < MAX_SKINS && (data = text = FS_LoadFile(va("%s_%i.skin", loadmodel->name, i), tempmempool, true));i++)
        {
                numtags = 0;
                skinfile = Mem_Alloc(tempmempool, sizeof(skinfile_t));
index 0f76f3727205c5e4e83f7a0f8fbd7165bd9649ec..3e1bd563c4b0666e9cbf9f34ed77f9a6dc8a6969 100644 (file)
--- a/palette.c
+++ b/palette.c
@@ -46,7 +46,7 @@ void Palette_Setup8to24(void)
        palette_complete[255] = 0; // completely transparent black
 
        // FIXME: fullbright_start should be read from colormap.lmp
-       colormap = FS_LoadFile("gfx/colormap.lmp", true);
+       colormap = FS_LoadFile("gfx/colormap.lmp", tempmempool, true);
        if (colormap && fs_filesize >= 16385)
                fullbright_start = 256 - colormap[16384];
        else
@@ -181,7 +181,7 @@ void Palette_Init(void)
        float gamma, scale, base;
        qbyte *pal;
        qbyte temp[256];
-       pal = (qbyte *)FS_LoadFile ("gfx/palette.lmp", false);
+       pal = (qbyte *)FS_LoadFile ("gfx/palette.lmp", tempmempool, false);
        if (pal && fs_filesize >= 768)
        {
                memcpy(host_basepal, pal, 765);
index 151e62f0dafaf64bb3357aed577c7a69fabcecbc..2f512093eff786f34dd3361aa4383d9999e0747c 100644 (file)
@@ -1251,7 +1251,6 @@ void PR_LoadProgs (void)
        int i;
        dstatement_t *st;
        ddef_t *infielddefs;
-       void *temp;
        dfunction_t *dfunctions;
 
 // flush the non-C variable lookup cache
@@ -1261,15 +1260,10 @@ void PR_LoadProgs (void)
        Mem_EmptyPool(progs_mempool);
        Mem_EmptyPool(edictstring_mempool);
 
-       temp = FS_LoadFile ("progs.dat", false);
-       if (!temp)
+       progs = (dprograms_t *)FS_LoadFile ("progs.dat", progs_mempool, false);
+       if (!progs)
                Host_Error ("PR_LoadProgs: couldn't load progs.dat");
 
-       progs = (dprograms_t *)Mem_Alloc(progs_mempool, fs_filesize);
-
-       memcpy(progs, temp, fs_filesize);
-       Mem_Free(temp);
-
        Con_DPrintf("Programs occupy %iK.\n", fs_filesize/1024);
 
        pr_crc = CRC_Block((qbyte *)progs, fs_filesize);
index bfc904d3a99600d9384035bf4a6382ba6992926a..f19deb65613ffa2d1f1eea3d1603b09f076daa3d 100644 (file)
@@ -2266,7 +2266,7 @@ void VM_loadfromfile(void)
        }
 
        // not conform with VM_fopen
-       data = FS_LoadFile(filename, false);
+       data = FS_LoadFile(filename, tempmempool, false);
        if (data == NULL)
                PRVM_G_FLOAT(OFS_RETURN) = -1;
        
index 4baf85d5e26b3f809bafe3723684153b51b29645..4cc5872462fa426560f1dc3d9eb9a50e0acfe070 100644 (file)
@@ -1269,21 +1269,15 @@ void PRVM_LoadProgs (const char * filename, int numrequiredfunc, char **required
        int i;
        dstatement_t *st;
        ddef_t *infielddefs;
-       void *temp;
        dfunction_t *dfunctions;
 
        Mem_EmptyPool(prog->progs_mempool);
        Mem_EmptyPool(prog->edictstring_mempool);
 
-       temp = FS_LoadFile (filename, false);
-       if (temp == 0)
+       prog->progs = (dprograms_t *)FS_LoadFile (filename, prog->progs_mempool, false);
+       if (prog->progs == NULL)
                PRVM_ERROR ("PRVM_LoadProgs: couldn't load %s for %s", filename, PRVM_NAME);
 
-       prog->progs = (dprograms_t *)Mem_Alloc(prog->progs_mempool, fs_filesize);
-
-       memcpy(prog->progs, temp, fs_filesize);
-       Mem_Free(temp);
-
        Con_DPrintf("%s programs occupy %iK.\n", PRVM_NAME, fs_filesize/1024);
 
        pr_crc = CRC_Block((qbyte *)prog->progs, fs_filesize);
index 72d06b22c32edc2e7b3ad05a64585660878cde09..ac7d08c18d4b9723dad0062a91943b7e0bcbf2fd 100644 (file)
@@ -2468,7 +2468,7 @@ void R_Shadow_LoadWorldLights(void)
        }
        FS_StripExtension (cl.worldmodel->name, name, sizeof (name));
        strlcat (name, ".rtlights", sizeof (name));
-       lightsstring = FS_LoadFile(name, false);
+       lightsstring = FS_LoadFile(name, tempmempool, false);
        if (lightsstring)
        {
                s = lightsstring;
@@ -2586,7 +2586,7 @@ void R_Shadow_LoadLightsFile(void)
        }
        FS_StripExtension (cl.worldmodel->name, name, sizeof (name));
        strlcat (name, ".lights", sizeof (name));
-       lightsstring = FS_LoadFile(name, false);
+       lightsstring = FS_LoadFile(name, tempmempool, false);
        if (lightsstring)
        {
                s = lightsstring;
index 94027d437fe3ac253b6af84bf799c90971e6d787..d0671eb8740fb88ef143148178beb8500933442f 100644 (file)
--- a/snd_mem.c
+++ b/snd_mem.c
@@ -221,7 +221,7 @@ sfxcache_t *S_LoadWavFile (const char *filename, sfx_t *s)
        sfxcache_t *sc;
 
        // Load the file
-       data = FS_LoadFile(filename, false);
+       data = FS_LoadFile(filename, tempmempool, false);
        if (!data)
                return NULL;
 
index 8acedc7c3d0362ede540b6fc821caf3b6f509136..bf7bd2a3f56f06d95d04d64dad76a2c6ff59ad6a 100644 (file)
--- a/snd_ogg.c
+++ b/snd_ogg.c
@@ -380,7 +380,7 @@ sfxcache_t *OGG_LoadVorbisFile (const char *filename, sfx_t *s)
                return NULL;
 
        // Load the file
-       data = FS_LoadFile (filename, false);
+       data = FS_LoadFile (filename, tempmempool, false);
        if (data == NULL)
                return NULL;
 
index d5b05b5d0fdf2ee55104a5e072a3226b69679616..4bd029285034556163168a49ce7ec4b6a1747ea7 100644 (file)
--- a/sv_main.c
+++ b/sv_main.c
@@ -1927,7 +1927,7 @@ void SV_SpawnServer (const char *server)
        // load replacement entity file if found
        entities = NULL;
        if (sv_entpatch.integer)
-               entities = FS_LoadFile(va("maps/%s.ent", sv.name), true);
+               entities = FS_LoadFile(va("maps/%s.ent", sv.name), tempmempool, true);
        if (entities)
        {
                Con_Printf("Loaded maps/%s.ent\n", sv.name);
diff --git a/wad.c b/wad.c
index c1ceb1260ecfb423e5dbd223598221edcaf8cc16..44f39f310273351c93f08a6714f614521a4111f7 100644 (file)
--- a/wad.c
+++ b/wad.c
@@ -73,7 +73,7 @@ void *W_GetLumpName(char *name)
        if (!wad_loaded)
        {
                wad_loaded = true;
-               if ((temp = FS_LoadFile ("gfx.wad", false)))
+               if ((temp = FS_LoadFile ("gfx.wad", tempmempool, false)))
                {
                        if (memcmp(temp, "WAD2", 4))
                                Con_Print("gfx.wad doesn't have WAD2 id\n");