Counter Strike : Global Offensive Source Code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.6 KiB

  1. //===== Copyright � 1996-2005, Valve Corporation, All rights reserved. ======//
  2. //
  3. // Purpose:
  4. //
  5. //===========================================================================//
  6. #ifndef MEM_HELPERS_H
  7. #define MEM_HELPERS_H
  8. #ifdef _WIN32
  9. #pragma once
  10. #endif
  11. // Normally, the runtime libraries like to mess with the memory returned by malloc(),
  12. // which can create problems trying to repro bugs in debug builds or in the debugger.
  13. //
  14. // If the debugger is present, it initializes data to 0xbaadf00d, which makes floating
  15. // point numbers come out to about 0.1.
  16. //
  17. // If the debugger is not present, and it's a debug build, then you get 0xcdcdcdcd,
  18. // which is about 25 million.
  19. //
  20. // Otherwise, you get uninitialized memory.
  21. //
  22. // In here, we make sure the memory is either random garbage, or it's set to
  23. // 0xffeeffee, which casts to a NAN.
  24. extern bool g_bInitMemory;
  25. #define ApplyMemoryInitializations( pMem, nSize ) if ( !g_bInitMemory ) ; else { DoApplyMemoryInitializations( pMem, nSize ); }
  26. void DoApplyMemoryInitializations( void *pMem, size_t nSize );
  27. #if IsPlatformWindowsPC()
  28. // Use this to override the allocator. This must be called before the first
  29. // allocation. This may not be available on all platforms.
  30. class IMemAlloc;
  31. void SetAllocatorObject( IMemAlloc* pAllocator );
  32. // Check for various allocator overrides such as -processheap and -reservelowmem.
  33. // Returns true if -processheap is enabled, by a command line switch or other method.
  34. bool CheckWindowsAllocSettings( const char* upperCommandLine );
  35. #else
  36. inline bool CheckWindowsAllocSettings( const char* upperCommandLine ) { return false; }
  37. #endif
  38. size_t CalcHeapUsed();
  39. #endif // MEM_HELPERS_H