MemoryPoolAddressSanitizer.h 845 B

12345678910111213141516171819202122232425262728293031
  1. #pragma once
  2. #include "il2cpp-config.h"
  3. #if !IL2CPP_SANITIZE_ADDRESS
  4. #error MemoryPoolAddressSanitizer should only be used when the address sanitizer is enabled
  5. #endif
  6. #include <vector>
  7. namespace il2cpp
  8. {
  9. namespace utils
  10. {
  11. // Use system allocators with the address sanitizer, so that it can catch
  12. // problems with memory access that might happen when our memory pool is
  13. // used incorrectly.
  14. class MemoryPoolAddressSanitizer
  15. {
  16. public:
  17. MemoryPoolAddressSanitizer();
  18. MemoryPoolAddressSanitizer(size_t initialSize);
  19. ~MemoryPoolAddressSanitizer();
  20. void* Malloc(size_t size);
  21. void* Calloc(size_t count, size_t size);
  22. size_t TotalSize();
  23. private:
  24. std::vector<void*> m_Allocations;
  25. size_t m_TotalSize;
  26. };
  27. } /* namespace utils */
  28. } /* namespace il2cpp */