Quirks.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #include "Quirks.h"
  2. #include <cstddef>
  3. #include <cstring>
  4. #include <memory>
  5. #include "Logger.h"
  6. using namespace WalrusRPG;
  7. void Quirks::init(const char *argv_0)
  8. {
  9. WalrusRPG::Logger::log("Quirks init");
  10. }
  11. void Quirks::deinit()
  12. {
  13. WalrusRPG::Logger::log("Quirks deinit");
  14. }
  15. std::unique_ptr<char> Quirks::solve_absolute_path(const char *path)
  16. {
  17. std::unique_ptr<char> result(new char[strlen(path) + 1]);
  18. strcpy(result.get(), path);
  19. return result;
  20. }
  21. #include <stdlib.h>
  22. #include <unistd.h> /* for write(), also available on Windows */
  23. extern "C" void* emulate_cc_new(unsigned len) { \
  24. void *p = malloc(len);
  25. if (p == 0) {
  26. /* Don't use stdio (e.g. fputs), because that may want to allocate more
  27. * memory.
  28. */
  29. (void)!write(2, "out of memory\n", 14);
  30. abort();
  31. }
  32. return p;
  33. }
  34. extern "C" void emulate_cc_delete(void* p) {
  35. if (p != 0)
  36. free(p);
  37. }
  38. void* operator new (unsigned len) __attribute__((alias("emulate_cc_new")));
  39. void* operator new[](unsigned len) __attribute__((alias("emulate_cc_new")));
  40. void operator delete (void* p) __attribute__((alias("emulate_cc_delete")));
  41. void operator delete[](void* p) __attribute__((alias("emulate_cc_delete")));
  42. extern "C" void __cxa_pure_virtual()
  43. {
  44. //while (1);
  45. }