codemp/game/g_mem.c File Reference

#include "g_local.h"

Go to the source code of this file.

Defines

#define POOLSIZE   (256 * 1024)

Functions

void * G_Alloc (int size)
void G_InitMemory (void)
void Svcmd_GameMem_f (void)


Define Documentation

#define POOLSIZE   (256 * 1024)
 

Definition at line 11 of file g_mem.c.

Referenced by G_Alloc(), and Svcmd_GameMem_f().


Function Documentation

void* G_Alloc int  size  ) 
 

Definition at line 16 of file g_mem.c.

References g_debugAlloc, G_Error(), G_Printf(), vmCvar_t::integer, NULL, and POOLSIZE.

Referenced by G_NewString(), G_ParseInfos(), Initialize(), and Q3_SetParm().

00016                           {
00017         char    *p;
00018 
00019         if ( g_debugAlloc.integer ) {
00020                 G_Printf( "G_Alloc of %i bytes (%i left)\n", size, POOLSIZE - allocPoint - ( ( size + 31 ) & ~31 ) );
00021         }
00022 
00023         if ( allocPoint + size > POOLSIZE ) {
00024           G_Error( "G_Alloc: failed on allocation of %i bytes\n", size ); // bk010103 - was %u, but is signed
00025                 return NULL;
00026         }
00027 
00028         p = &memoryPool[allocPoint];
00029 
00030         allocPoint += ( size + 31 ) & ~31;
00031 
00032         return p;
00033 }

void G_InitMemory void   ) 
 

Definition at line 35 of file g_mem.c.

Referenced by G_InitGame().

00035                           {
00036         allocPoint = 0;
00037 }

void Svcmd_GameMem_f void   ) 
 

Definition at line 39 of file g_mem.c.

References G_Printf(), and POOLSIZE.

Referenced by ConsoleCommand().

00039                              {
00040         G_Printf( "Game memory status: %i out of %i bytes allocated\n", allocPoint, POOLSIZE );
00041 }