2
0

CustomMemoryHook.h 916 B

12345678910111213141516171819202122232425262728
  1. // SPDX-FileCopyrightText: 2021 Jorrit Rouwe
  2. // SPDX-License-Identifier: MIT
  3. #pragma once
  4. #if defined(_DEBUG) && !defined(JPH_DISABLE_CUSTOM_ALLOCATOR) && !defined(JPH_COMPILER_MINGW)
  5. /// Register hook that detects allocations that aren't made through the custom allocator
  6. void RegisterCustomMemoryHook();
  7. /// Enable the custom memory hook to detect allocations not made through the custom allocator
  8. void EnableCustomMemoryHook(bool inEnable);
  9. /// Check if the hook is currently checking allocations
  10. bool IsCustomMemoryHookEnabled();
  11. #else
  12. inline void RegisterCustomMemoryHook() { RegisterDefaultAllocator(); }
  13. #endif // _DEBUG && !JPH_DISABLE_CUSTOM_ALLOCATOR && !JPH_COMPILER_MINGW
  14. /// Struct that, when put on the stack, temporarily disables checking that all allocations go through the custom memory allocator
  15. struct DisableCustomMemoryHook
  16. {
  17. DisableCustomMemoryHook();
  18. ~DisableCustomMemoryHook();
  19. };