Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

l_mem.c File Reference

#include "qbsp.h"
#include "l_log.h"

Include dependency graph for l_mem.c:

Include dependency graph

Go to the source code of this file.

Data Structures

struct  memhunk_s

Typedefs

typedef memhunk_s memhunk_t

Functions

void FreeMemory (void *ptr)
void * GetClearedMemory (int size)
void * GetMemory (unsigned long size)
void * Hunk_Alloc (int size)
void Hunk_ClearHigh (void)
int MemorySize (void *ptr)
void PrintMemorySize (unsigned long size)
int TotalAllocatedMemory (void)
void Z_Free (void *ptr)
void * Z_Malloc (int size)

Variables

int allocedmemory
memhunk_tmemhunk_high
int memhunk_high_size = 16 * 1024 * 1024
memhunk_tmemhunk_low
int memhunk_low_size = 0


Typedef Documentation

typedef struct memhunk_s memhunk_t
 

Referenced by Hunk_Alloc(), and Hunk_ClearHigh().


Function Documentation

void FreeMemory void *  ptr  ) 
 

Definition at line 103 of file l_mem.c.

References allocedmemory, botimport, free(), botlib_import_s::FreeMemory, MemorySize(), and ptr().

Referenced by AAS_CalculateAreaTravelTimes(), AAS_ContinueInitReachability(), AAS_CreateReversedReachability(), AAS_DumpAASData(), AAS_DumpBSPData(), AAS_FreeAASLinkedEntities(), AAS_FreeAASLinkHeap(), AAS_FreeAllClusterAreaCache(), AAS_FreeAllPortalCache(), AAS_FreeBSPEntities(), AAS_FreeMaxAAS(), AAS_FreeRoutingCache(), AAS_FreeRoutingCaches(), AAS_FreeTmpAAS(), AAS_FreeTmpArea(), AAS_FreeTmpFace(), AAS_InitAASLinkedEntities(), AAS_InitAlternativeRouting(), AAS_InitAreaContentsTravelFlags(), AAS_InitClustering(), AAS_InitPortalMaxTravelTimes(), AAS_InitReachabilityAreas(), AAS_InitRoutingUpdate(), AAS_LoadAASLump(), AAS_OptimizeStore(), AAS_Setup(), AAS_Shutdown(), AAS_ShutdownAlternativeRouting(), AAS_ShutDownReachabilityHeap(), AAS_StoreReachability(), BotCheckInitialChatIntegrety(), BotCheckReplyChatIntegrety(), BotFreeCharacter2(), BotFreeCharacterStrings(), BotFreeChatFile(), BotFreeChatState(), BotFreeGoalState(), BotFreeInfoEntities(), BotFreeItemWeights(), BotFreeMatchPieces(), BotFreeMatchTemplates(), BotFreeMoveState(), BotFreeReplyChat(), BotFreeWeaponState(), BotFreeWeaponWeights(), BotInitInfoEntities(), BotLoadCharacterFromFile(), BotShutdownChatAI(), BotShutdownGoalAI(), BotShutdownMoveAI(), BotShutdownWeaponAI(), EA_Shutdown(), EndBSPFile(), FindMiptex(), FreeBrush(), FreeFace(), FreeFuzzySeperators_r(), FreePortal(), FreeScript(), FreeSource(), FreeValueKeys(), FreeWeightConfig2(), FreeWinding(), FS_FreeFile(), HL_FreeMaxBSP(), HL_LoadBSPFile(), Hunk_ClearHigh(), InitConsoleMessageHeap(), InitLevelItemHeap(), LibVarDeAlloc(), LibVarSet(), LoadItemConfig(), LoadScriptFile(), LoadWeaponConfig(), PC_DefineFromString(), PC_FreeDefine(), PC_FreeToken(), PC_PopIndent(), Q1_FreeMaxBSP(), Q1_LoadBSPFile(), Q2_FreeMaxBSP(), Q2_LoadBSPFile(), Q2_LoadBSPFileTexinfo(), Q2_MoveBrushesToWorld(), Q3_FreeMaxBSP(), Q3_LoadBSPFile(), QCopyFile(), ReadWeightConfig(), ResetMapLoading(), SetKeyValue(), Sin_FreeMaxBSP(), Sin_LoadBSPFile(), Sin_LoadBSPFileTexinfo(), TH_FreeMaxTH(), Tree_Free(), Tree_Free_r(), Tree_PruneNodes_r(), and Z_Free().

00104 {
00105     allocedmemory -= MemorySize(ptr);
00106     free(ptr);
00107 } //end of the function FreeMemory

Here is the call graph for this function:

void* GetClearedMemory int  size  ) 
 

Definition at line 73 of file l_mem.c.

References allocedmemory, Error(), malloc(), MemorySize(), memset(), and ptr().

Referenced by AAS_AllocMaxAAS(), AAS_AllocRoutingCache(), AAS_AllocTmpArea(), AAS_AllocTmpFace(), AAS_AllocTmpNode(), AAS_CalculateAreaTravelTimes(), AAS_CreateAreaSettings(), AAS_CreateReversedReachability(), AAS_FloodAreas(), AAS_InitAreaContentsTravelFlags(), AAS_InitClusterAreaCache(), AAS_InitClustering(), AAS_InitPortalCache(), AAS_InitPortalMaxTravelTimes(), AAS_InitReachability(), AAS_InitReachabilityAreas(), AAS_InitRoutingUpdate(), AAS_LoadAASLump(), AAS_NearestHideArea(), AAS_OptimizeAlloc(), AAS_SetupReachabilityHeap(), AAS_StoreReachability(), BotAllocChatState(), BotAllocGoalState(), BotAllocMoveState(), BotAllocWeaponState(), BotCheckChatMessageIntegrety(), BotInitInfoEntities(), BotInterpolateCharacters(), BotLoadCharacterFromFile(), BotLoadChatFile(), BotLoadInitialChat(), Hunk_Alloc(), InitLevelItemHeap(), ItemWeightIndex(), LoadScriptFile(), LoadScriptMemory(), LoadSourceFile(), LoadSourceMemory(), PC_DefineFromString(), Q2_AllocMaxBSP(), Q3_CreatePlanarSurfacePlanes(), ReadFuzzySeperators_r(), ReadWeightConfig(), Sin_AllocMaxBSP(), TH_InitMaxTH(), WeaponWeightIndex(), and Z_Malloc().

00074 {
00075     void *ptr;
00076 
00077     ptr = (void *) malloc(size);
00078     if (!ptr) Error("out of memory");
00079     memset(ptr, 0, size);
00080     allocedmemory += MemorySize(ptr);
00081     return ptr;
00082 } //end of the function GetClearedMemory

Here is the call graph for this function:

void* GetMemory unsigned long  size  ) 
 

Definition at line 89 of file l_mem.c.

References allocedmemory, botimport, Error(), botlib_import_s::GetMemory, malloc(), MemorySize(), and ptr().

Referenced by AAS_InitAlternativeRouting(), AAS_ReadCache(), AAS_UpdateStringIndexes(), AllocBrush(), AllocFace(), AllocNode(), AllocPortal(), AllocWinding(), BotDefaultCharacteristics(), BotImport_GetMemory(), BotInterpolateCharacters(), BotLoadCharacterFromFile(), copystring(), GetClearedMemory(), HL_AllocMaxBSP(), LibVar(), LibVarAlloc(), LibVarSet(), LoadFile(), LoadQuakeFile(), LoadSourceFile(), LoadSourceMemory(), ParseEpair(), PC_AddBuiltinDefines(), PC_CopyDefine(), PC_CopyToken(), PC_Directive_define(), PC_PushIndent(), PS_CreatePunctuationTable(), Q1_AllocMaxBSP(), Q2_LoadBSPFileTexinfo(), Q2_MoveBrushesToWorld(), Q3_CopyLump(), SetKeyValue(), Sin_LoadBSPFileTexinfo(), Tree_Alloc(), and TryLoadFile().

00090 {
00091     void *ptr;
00092     ptr = malloc(size);
00093     if (!ptr) Error("out of memory");
00094     allocedmemory += MemorySize(ptr);
00095     return ptr;
00096 } //end of the function GetMemory

Here is the call graph for this function:

void* Hunk_Alloc int  size  ) 
 

Definition at line 409 of file l_mem.c.

References GetClearedMemory(), h(), memhunk_high, memhunk_high_size, memhunk_t, memhunk_s::next, and memhunk_s::ptr.

00410 {
00411     memhunk_t *h;
00412 
00413     if (!size) return (void *) memhunk_high_size;
00414     //
00415     h = GetClearedMemory(size + sizeof(memhunk_t));
00416     h->ptr = (char *) h + sizeof(memhunk_t);
00417     h->next = memhunk_high;
00418     memhunk_high = h;
00419     memhunk_high_size -= size;
00420     return h->ptr;
00421 } //end of the function Hunk_Alloc

Here is the call graph for this function:

void Hunk_ClearHigh void   ) 
 

Definition at line 391 of file l_mem.c.

References FreeMemory(), h(), memhunk_high, memhunk_high_size, memhunk_t, and memhunk_s::next.

00392 {
00393     memhunk_t *h, *nexth;
00394 
00395     for (h = memhunk_high; h; h = nexth)
00396     {
00397         nexth = h->next;
00398         FreeMemory(h);
00399     } //end for
00400     memhunk_high = NULL;
00401     memhunk_high_size = 16 * 1024 * 1024;
00402 } //end of the function Hunk_ClearHigh

Here is the call graph for this function:

int MemorySize void *  ptr  ) 
 

Definition at line 54 of file l_mem.c.

References ptr().

Referenced by AllocBrush(), AllocNode(), AllocPortal(), AllocWinding(), FreeBrush(), FreeMemory(), FreePortal(), FreeWinding(), GetClearedMemory(), GetMemory(), Tree_Free(), Tree_Free_r(), and Tree_FreePortals_r().

00055 {
00056 #if defined(WIN32) || defined(_WIN32)
00057     #ifdef __WATCOMC__
00058         //Intel 32 bits memory addressing, 16 bytes aligned
00059     return (_msize(ptr) + 15) >> 4 << 4;
00060     #else
00061     return _msize(ptr);
00062     #endif
00063 #else
00064     return 0;
00065 #endif
00066 } //end of the function MemorySize

Here is the call graph for this function:

void PrintMemorySize unsigned long  size  ) 
 

Definition at line 34 of file l_mem.c.

References Log_Print().

Referenced by AAS_AllocMaxAAS(), AAS_FreeMaxAAS(), HL_AllocMaxBSP(), HL_FreeMaxBSP(), Q1_AllocMaxBSP(), Q1_FreeMaxBSP(), Q2_AllocMaxBSP(), Q2_FreeMaxBSP(), Sin_AllocMaxBSP(), Sin_FreeMaxBSP(), and Tree_Free().

00035 {
00036     unsigned long number1, number2, number3;
00037     number1 = size >> 20;
00038     number2 = (size & 0xFFFFF) >> 10;
00039     number3 = (size & 0x3FF);
00040     if (number1) Log_Print("%ld MB", number1);
00041     if (number1 && number2) Log_Print(" and ");
00042     if (number2) Log_Print("%ld KB", number2);
00043     if (number2 && number3) Log_Print(" and ");
00044     if (number3) Log_Print("%ld bytes", number3);
00045 } //end of the function PrintFileSize

Here is the call graph for this function:

int TotalAllocatedMemory void   ) 
 

Definition at line 114 of file l_mem.c.

00115 {
00116     return allocedmemory;
00117 } //end of the function TotalAllocatedMemory

void Z_Free void *  ptr  ) 
 

Definition at line 438 of file l_mem.c.

00439 {
00440     FreeMemory(ptr);
00441 } //end of the function Z_Free

void* Z_Malloc int  size  ) 
 

Definition at line 428 of file l_mem.c.

00429 {
00430     return GetClearedMemory(size);
00431 } //end of the function Z_Malloc


Variable Documentation

int allocedmemory
 

Definition at line 26 of file l_mem.c.

Referenced by FreeMemory(), GetClearedMemory(), and GetMemory().

memhunk_t* memhunk_high
 

Definition at line 380 of file l_mem.c.

Referenced by Hunk_Alloc(), and Hunk_ClearHigh().

int memhunk_high_size = 16 * 1024 * 1024
 

Definition at line 382 of file l_mem.c.

Referenced by Hunk_Alloc(), and Hunk_ClearHigh().

memhunk_t* memhunk_low
 

Definition at line 381 of file l_mem.c.

int memhunk_low_size = 0
 

Definition at line 383 of file l_mem.c.


Generated on Thu Aug 25 12:54:23 2005 for Quake III Arena by  doxygen 1.3.9.1