CmMemAllocProfiler.h 777 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #pragma once
  2. namespace CamelotFramework
  3. {
  4. /**
  5. * @brief Specialized allocator for profiler so we can avoid tracking internal profiler memory allocations
  6. */
  7. class ProfilerAlloc
  8. {};
  9. /**
  10. * @brief Memory allocator providing a generic implementation.
  11. * Specialize for specific categories as needed.
  12. */
  13. template<>
  14. class MemoryAllocator<ProfilerAlloc> : public MemoryAllocatorBase
  15. {
  16. public:
  17. static inline void* allocate(UINT32 bytes)
  18. {
  19. return malloc(bytes);
  20. }
  21. static inline void* allocateArray(UINT32 bytes, UINT32 count)
  22. {
  23. return malloc(bytes * count);
  24. }
  25. static inline void free(void* ptr)
  26. {
  27. ::free(ptr);
  28. }
  29. static inline void freeArray(void* ptr, UINT32 count)
  30. {
  31. ::free(ptr);
  32. }
  33. };
  34. }