2
0

CustomMemoryHook.h 980 B

1234567891011121314151617181920212223242526272829
  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(_DEBUG) && !defined(JPH_DISABLE_CUSTOM_ALLOCATOR) && !defined(JPH_COMPILER_MINGW)
  6. /// Register hook that detects allocations that aren't made through the custom allocator
  7. void RegisterCustomMemoryHook();
  8. /// Enable the custom memory hook to detect allocations not made through the custom allocator
  9. void EnableCustomMemoryHook(bool inEnable);
  10. /// Check if the hook is currently checking allocations
  11. bool IsCustomMemoryHookEnabled();
  12. #else
  13. inline void RegisterCustomMemoryHook() { RegisterDefaultAllocator(); }
  14. #endif // _DEBUG && !JPH_DISABLE_CUSTOM_ALLOCATOR && !JPH_COMPILER_MINGW
  15. /// Struct that, when put on the stack, temporarily disables checking that all allocations go through the custom memory allocator
  16. struct DisableCustomMemoryHook
  17. {
  18. DisableCustomMemoryHook();
  19. ~DisableCustomMemoryHook();
  20. };