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.

49 lines
1.5 KiB

  1. //--------------------------------------------------------------------------------------------------
  2. // qhMemory.cpp
  3. //
  4. // Copyright(C) 2011 by D. Gregorius. All rights reserved.
  5. //--------------------------------------------------------------------------------------------------
  6. #include "qhMemory.h"
  7. #include "qhTypes.h"
  8. #include <stdlib.h>
  9. //--------------------------------------------------------------------------------------------------
  10. // Local utilities
  11. //--------------------------------------------------------------------------------------------------
  12. static void* qhDefaultAlloc( size_t Bytes )
  13. {
  14. return malloc( Bytes );
  15. }
  16. //--------------------------------------------------------------------------------------------------
  17. static void qhDefaultFree( void* Address )
  18. {
  19. return free( Address );
  20. }
  21. //--------------------------------------------------------------------------------------------------
  22. // qhMemory
  23. //--------------------------------------------------------------------------------------------------
  24. void* (*qhAllocHook)( size_t ) = qhDefaultAlloc;
  25. void (*qhFreeHook)( void* ) = qhDefaultFree;
  26. //--------------------------------------------------------------------------------------------------
  27. void* qhAlloc( size_t Bytes )
  28. {
  29. QH_ASSERT( qhAllocHook != NULL );
  30. return qhAllocHook( Bytes );
  31. }
  32. //--------------------------------------------------------------------------------------------------
  33. void qhFree( void* Address )
  34. {
  35. QH_ASSERT( qhFreeHook != NULL );
  36. qhFreeHook( Address );
  37. }