CustomMemoryHook.h 1.1 KB

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