104 lines · 2.4 KB · C
RawDownload
/* memory allocation H_??? The hunk manages the entire memory block given to quake. It must becontiguous. Memory can be allocated from either the low or high end in astack fashion. The only way memory is released is by resetting one of thepointers. Hunk allocations should be given a name, so the Hunk_Print () functioncan display usage. Hunk allocations are guaranteed to be 16 byte aligned. The video buffers are allocated high to avoid leaving a hole underneathserver allocations when changing to a higher video mode. Z_??? Zone memory functions used for small, dynamic allocations like textstrings from command input. There is only about 48K for it, allocated atthe very bottom of the hunk. Cache_??? Cache memory is for objects that can be dynamically loaded andcan usefully stay persistant between levels. The size of the cachefluctuates from level to level. To allocate a cachable object Temp_??? Temp memory is used for file loading and surface caching. The sizeof the cache memory is adjusted so that there is a minimum of 512k remainingfor temp memory. ------ Top of Memory ------- high hunk allocations <--- high hunk reset point held by vid video buffer z buffer surface cache <--- high hunk used cachable memory <--- low hunk used client and server low hunk allocations <-- low hunk reset point held by host startup hunk allocations Zone block ----- Bottom of Memory ----- */ void Memory_Init (void *buf, int size); void Z_Free (void *ptr);void *Z_Malloc (int size); // returns 0 filled memoryvoid *Z_TagMalloc (int size, int tag); void Z_DumpHeap (void);void Z_CheckHeap (void);int Z_FreeMemory (void); void *Hunk_Alloc (int size); // returns 0 filled memoryvoid *Hunk_AllocName (int size, char *name); void *Hunk_HighAllocName (int size, char *name); int Hunk_LowMark (void);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{	void *data;} cache_user_t; void Cache_Flush (void); void *Cache_Check (cache_user_t *c);// returns the cached data, and moves to the head of the LRU list// if present, otherwise returns NULL void Cache_Free (cache_user_t *c); void *Cache_Alloc (cache_user_t *c, int size, char *name);// Returns NULL if all purgable data was tossed and there still// wasn't enough room. void Cache_Report (void); 

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t