use_after_free_checker.h 583 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include <util/system/platform.h>
  3. #include <util/system/types.h>
  4. class TUseAfterFreeChecker {
  5. private:
  6. ui64 Magic;
  7. public:
  8. TUseAfterFreeChecker();
  9. ~TUseAfterFreeChecker();
  10. void CheckNotFreed() const;
  11. };
  12. // check twice: in constructor and in destructor
  13. class TUseAfterFreeCheckerGuard {
  14. private:
  15. const TUseAfterFreeChecker& Check;
  16. public:
  17. TUseAfterFreeCheckerGuard(const TUseAfterFreeChecker& check)
  18. : Check(check)
  19. {
  20. Check.CheckNotFreed();
  21. }
  22. ~TUseAfterFreeCheckerGuard() {
  23. Check.CheckNotFreed();
  24. }
  25. };