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.

78 lines
2.0 KiB

  1. //--------------------------------------------------------------------------------------------------
  2. /**
  3. @file qhMemory.h
  4. @author Dirk Gregorius
  5. @version 0.1
  6. @date 30/11/2011
  7. Copyright(C) 2011 by D. Gregorius. All rights reserved.
  8. */
  9. //--------------------------------------------------------------------------------------------------
  10. #pragma once
  11. #include <new>
  12. //--------------------------------------------------------------------------------------------------
  13. // qhMemory
  14. //--------------------------------------------------------------------------------------------------
  15. extern void* (*qhAllocHook)( std::size_t );
  16. extern void (*qhFreeHook)( void* );
  17. void* qhAlloc( std::size_t Bytes );
  18. void qhFree( void* Address );
  19. //--------------------------------------------------------------------------------------------------
  20. // qhPool
  21. //--------------------------------------------------------------------------------------------------
  22. template < typename T >
  23. class qhPool
  24. {
  25. public:
  26. qhPool( void );
  27. ~qhPool( void );
  28. void Clear( void );
  29. void Resize( int Size );
  30. T* Allocate( void );
  31. void Free( T* Address );
  32. private:
  33. int mSize;
  34. T* mPool;
  35. int mFree;
  36. // Non-copyable
  37. qhPool( const qhPool& );
  38. qhPool& operator=( const qhPool& );
  39. };
  40. //--------------------------------------------------------------------------------------------------
  41. // Memory utilities
  42. //--------------------------------------------------------------------------------------------------
  43. template < typename T >
  44. void qhConstruct( T* Address );
  45. template < typename T >
  46. void qhConstruct( T* Address, int N );
  47. template < typename T >
  48. void qhCopyConstruct( T* Address, const T& Other );
  49. template < typename T >
  50. void qhDestroy( T* Address );
  51. template < typename T >
  52. void qhDestroy( T* Address, int N );
  53. template < typename T >
  54. void qhMove( T* address, T* Begin, T* End );
  55. template < typename T >
  56. void qhSwap( T& Lhs, T& Rhs );
  57. const void* qhAddByteOffset( const void* Address, std::size_t Bytes );
  58. #include "qhMemory.inl"