|
|
1.1 root 1: /*
2: memory allocation
3:
4:
5: H_??? The hunk manages the entire memory block given to quake. It must be
6: contiguous. Memory can be allocated from either the low or high end in a
7: stack fashion. The only way memory is released is by resetting one of the
8: pointers.
9:
10: Hunk allocations should be given a name, so the Hunk_Print () function
11: can display usage.
12:
13: Hunk allocations are guaranteed to be 16 byte aligned.
14:
15: The video buffers are allocated high to avoid leaving a hole underneath
16: server allocations when changing to a higher video mode.
17:
18:
19: Z_??? Zone memory functions used for small, dynamic allocations like text
20: strings from command input. There is only about 48K for it, allocated at
21: the very bottom of the hunk.
22:
23: Cache_??? Cache memory is for objects that can be dynamically loaded and
24: can usefully stay persistant between levels. The size of the cache
25: fluctuates from level to level.
26:
27: To allocate a cachable object
28:
29:
30: Temp_??? Temp memory is used for file loading and surface caching. The size
31: of the cache memory is adjusted so that there is a minimum of 512k remaining
32: for temp memory.
33:
34:
35: ------ Top of Memory -------
36:
37: high hunk allocations
38:
39: <--- high hunk reset point held by vid
40:
41: video buffer
42:
43: z buffer
44:
45: surface cache
46:
47: <--- high hunk used
48:
49: cachable memory
50:
51: <--- low hunk used
52:
53: client and server low hunk allocations
54:
55: <-- low hunk reset point held by host
56:
57: startup hunk allocations
58:
59: Zone block
60:
61: ----- Bottom of Memory -----
62:
63:
64:
65: */
66:
67: void Memory_Init (void *buf, int size);
68:
69: void Z_Free (void *ptr);
70: void *Z_Malloc (int size); // returns 0 filled memory
71: void *Z_TagMalloc (int size, int tag);
72:
73: void Z_DumpHeap (void);
74: void Z_CheckHeap (void);
75: int Z_FreeMemory (void);
76:
77: void *Hunk_Alloc (int size); // returns 0 filled memory
78: void *Hunk_AllocName (int size, char *name);
79:
80: void *Hunk_HighAllocName (int size, char *name);
81:
82: int Hunk_LowMark (void);
83: void Hunk_FreeToLowMark (int mark);
84:
85: int Hunk_HighMark (void);
86: void Hunk_FreeToHighMark (int mark);
87:
88: void *Hunk_TempAlloc (int size);
89:
90: void Hunk_Check (void);
91:
92: typedef struct cache_user_s
93: {
94: void *data;
95: } cache_user_t;
96:
97: void Cache_Flush (void);
98:
99: void *Cache_Check (cache_user_t *c);
100: // returns the cached data, and moves to the head of the LRU list
101: // if present, otherwise returns NULL
102:
103: void Cache_Free (cache_user_t *c);
104:
105: void *Cache_Alloc (cache_user_t *c, int size, char *name);
106: // Returns NULL if all purgable data was tossed and there still
107: // wasn't enough room.
108:
109: void Cache_Report (void);
110:
111:
112:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.