00001
00002
00003
00004
00005
00006
00007
00008 #include "g_local.h"
00009
00010
00011 #define POOLSIZE (256 * 1024)
00012
00013 static char memoryPool[POOLSIZE];
00014 static int allocPoint;
00015
00016 void *G_Alloc( int size ) {
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 );
00025 return NULL;
00026 }
00027
00028 p = &memoryPool[allocPoint];
00029
00030 allocPoint += ( size + 31 ) & ~31;
00031
00032 return p;
00033 }
00034
00035 void G_InitMemory( void ) {
00036 allocPoint = 0;
00037 }
00038
00039 void Svcmd_GameMem_f( void ) {
00040 G_Printf( "Game memory status: %i out of %i bytes allocated\n", allocPoint, POOLSIZE );
00041 }