g_mem.cpp 671 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. //
  2. // g_mem.c
  3. //
  4. // leave this line at the top for all g_xxxx.cpp files...
  5. #include "g_headers.h"
  6. #include "g_local.h"
  7. /*#define POOLSIZE (2 * 1024 * 1024)
  8. static char memoryPool[POOLSIZE];
  9. */
  10. static int allocPoint;
  11. static cvar_t *g_debugalloc;
  12. void *G_Alloc( int size ) {
  13. if ( g_debugalloc->integer ) {
  14. gi.Printf( "G_Alloc of %i bytes\n", size );
  15. }
  16. allocPoint += size;
  17. return gi.Malloc(size, TAG_G_ALLOC, qfalse);
  18. }
  19. void G_InitMemory( void ) {
  20. allocPoint = 0;
  21. g_debugalloc = gi.cvar ("g_debugalloc", "0", 0);
  22. }
  23. void Svcmd_GameMem_f( void ) {
  24. gi.Printf( "Game memory status: %i allocated\n", allocPoint );
  25. }