ErrorSimulator.hpp 714 B

12345678910111213141516171819202122232425262728
  1. #ifndef CORE_ERROR_SIMULATOR_HPP
  2. #define CORE_ERROR_SIMULATOR_HPP
  3. #include "core/utils/Utility.hpp"
  4. #ifdef ERROR_SIMULATOR
  5. namespace Core::Fail {
  6. extern bool realloc;
  7. extern bool fileClose;
  8. extern bool timeGet;
  9. extern int leftAllocations;
  10. inline bool freeAndReturn(void* p) {
  11. Core::free(p);
  12. return true;
  13. }
  14. }
  15. #define CORE_REALLOC_FAIL(pointer) \
  16. (Core::Fail::realloc && Core::Fail::freeAndReturn(pointer))
  17. #define CORE_FILE_CLOSE_FAIL Core::Fail::fileClose
  18. #define CORE_TIME_GET_FAIL Core::Fail::timeGet
  19. #else
  20. #define CORE_REALLOC_FAIL false
  21. #define CORE_FILE_CLOSE_FAIL false
  22. #define CORE_TIME_GET_FAIL false
  23. #endif
  24. #endif