MemoryPoolAddressSanitizer.h 789 B

1234567891011121314151617181920212223242526272829
  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. private:
  23. std::vector<void*> m_Allocations;
  24. };
  25. } /* namespace utils */
  26. } /* namespace il2cpp */