diff options
author | Simon Howard | 2008-05-02 18:48:43 +0000 |
---|---|---|
committer | Simon Howard | 2008-05-02 18:48:43 +0000 |
commit | 3f54daeaa3acf590569cb397eee24731f7de6c17 (patch) | |
tree | ded285d0820cddae98b9e5c458f757c8c9ba3234 /src/w_wad.c | |
parent | 6b1ac97d99599ed5e8d8557313237f3ebb102ead (diff) | |
download | chocolate-doom-3f54daeaa3acf590569cb397eee24731f7de6c17.tar.gz chocolate-doom-3f54daeaa3acf590569cb397eee24731f7de6c17.tar.bz2 chocolate-doom-3f54daeaa3acf590569cb397eee24731f7de6c17.zip |
Add W_CacheLumpNum,Name API to WAD code for releasing a lump back to
cache when it is no longer needed. Switch existing code to use the new
API instead of Z_ChangeTag.
Subversion-branch: /trunk/chocolate-doom
Subversion-revision: 1134
Diffstat (limited to 'src/w_wad.c')
-rw-r--r-- | src/w_wad.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/w_wad.c b/src/w_wad.c index becdcf71..8960bb92 100644 --- a/src/w_wad.c +++ b/src/w_wad.c @@ -457,6 +457,15 @@ void W_ReadLump(unsigned int lump, void *dest) // // W_CacheLumpNum // +// Load a lump into memory and return a pointer to a buffer containing +// the lump data. +// +// 'tag' is the type of zone memory buffer to allocate for the lump +// (usually PU_STATIC or PU_CACHE). If the lump is loaded as +// PU_STATIC, it should be released back using W_ReleaseLumpNum +// when no longer needed (do not use Z_ChangeTag). +// + void *W_CacheLumpNum(int lump, int tag) { byte* ptr; @@ -491,6 +500,31 @@ void *W_CacheLumpName(char *name, int tag) return W_CacheLumpNum(W_GetNumForName(name), tag); } +// +// Release a lump back to the cache, so that it can be reused later +// without having to read from disk again, or alternatively, discarded +// if we run out of memory. +// +// Back in Vanilla Doom, this was just done using Z_ChangeTag +// directly, but now that we have WAD mmap, things are a bit more +// complicated ... +// + +void W_ReleaseLumpNum(int lump) +{ + if ((unsigned)lump >= numlumps) + { + I_Error ("W_ReleaseLumpNum: %i >= numlumps", lump); + } + + Z_ChangeTag(lumpinfo[lump].cache, PU_CACHE); +} + +void W_ReleaseLumpName(char *name) +{ + W_ReleaseLumpNum(W_GetNumForName(name)); +} + #if 0 // |