2 Copyright (C) 1996-1997 Id Software, Inc.
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 See the GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 H_??? The hunk manages the entire memory block given to quake. It must be
25 contiguous. Memory can be allocated from either the low or high end in a
26 stack fashion. The only way memory is released is by resetting one of the
29 Hunk allocations should be given a name, so the Hunk_Print () function
32 Hunk allocations are guaranteed to be 16 byte aligned.
34 The video buffers are allocated high to avoid leaving a hole underneath
35 server allocations when changing to a higher video mode.
38 Z_??? Zone memory functions used for small, dynamic allocations like text
39 strings from command input. There is only about 48K for it, allocated at
40 the very bottom of the hunk.
42 Cache_??? Cache memory is for objects that can be dynamically loaded and
43 can usefully stay persistant between levels. The size of the cache
44 fluctuates from level to level.
46 To allocate a cachable object
49 Temp_??? Temp memory is used for file loading and surface caching. The size
50 of the cache memory is adjusted so that there is a minimum of 512k remaining
54 ------ Top of Memory -------
58 <--- high hunk reset point held by vid
72 client and server low hunk allocations
74 <-- low hunk reset point held by host
76 startup hunk allocations
80 ----- Bottom of Memory -----
86 void Memory_Init (void *buf
, int size
);
88 void Z_Free (void *ptr
);
89 void *Z_Malloc (int size
); // returns 0 filled memory
90 void *Z_TagMalloc (int size
, int tag
);
92 void Z_DumpHeap (void);
93 void Z_CheckHeap (void);
94 int Z_FreeMemory (void);
96 void *Hunk_Alloc (int size
); // returns 0 filled memory
97 void *Hunk_AllocName (int size
, char *name
);
99 void *Hunk_HighAllocName (int size
, char *name
);
101 int Hunk_LowMark (void);
102 void Hunk_FreeToLowMark (int mark
);
104 int Hunk_HighMark (void);
105 void Hunk_FreeToHighMark (int mark
);
107 void *Hunk_TempAlloc (int size
);
109 void Hunk_Check (void);
111 typedef struct cache_user_s
116 void Cache_Flush (void);
118 void *Cache_Check (cache_user_t
*c
);
119 // returns the cached data, and moves to the head of the LRU list
120 // if present, otherwise returns NULL
122 void Cache_Free (cache_user_t
*c
);
124 void *Cache_Alloc (cache_user_t
*c
, int size
, char *name
);
125 // Returns NULL if all purgable data was tossed and there still
126 // wasn't enough room.
128 void Cache_Report (void);