diff --git a/CMakeLists.txt b/CMakeLists.txt index 60bd3ab..bff4f24 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,7 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") add_compile_options(/source-charset:utf-8) add_compile_options(/execution-charset:utf-8) endif () +add_compile_options(/Zc:preprocessor) include(CTest) enable_testing() diff --git a/Chars.h b/Chars.h index 1a15acc..fbb6729 100644 Binary files a/Chars.h and b/Chars.h differ diff --git a/Game.cpp b/Game.cpp index 27c0215..5a2c13c 100644 Binary files a/Game.cpp and b/Game.cpp differ diff --git a/Game.h b/Game.h index 9c8533d..2a2b1df 100644 Binary files a/Game.h and b/Game.h differ diff --git a/IText.cpp b/IText.cpp index e69cb48..10af54c 100644 Binary files a/IText.cpp and b/IText.cpp differ diff --git a/Renderer.h b/Renderer.h index 3cfdfba..24d2730 100644 Binary files a/Renderer.h and b/Renderer.h differ diff --git a/Window.cpp b/Window.cpp index 76fd8c2..cbcff94 100644 Binary files a/Window.cpp and b/Window.cpp differ diff --git a/Window.h b/Window.h index da7920a..98288d3 100644 Binary files a/Window.h and b/Window.h differ diff --git a/def.cpp b/def.cpp index 67eb6c8..4defbef 100644 Binary files a/def.cpp and b/def.cpp differ diff --git a/def.h b/def.h index 34c97cc..46cee1d 100644 Binary files a/def.h and b/def.h differ diff --git a/gc.h b/gc.h index edacaa4..8d4b3ef 100644 --- a/gc.h +++ b/gc.h @@ -30,10 +30,10 @@ class Garbage final : public IGarbage { public: explicit Garbage(T* ptr) : IGarbage(ptr) {} - void collect() override { delete static_cast(ptr); } + void collect() override { delete static_cast(deallocating(ptr)); } protected: - void deleteThis() override { delete this; } + void deleteThis() override { delete deallocating(this); } }; class GarbageCollector { @@ -76,7 +76,7 @@ public: /** 只能在gameThread调用 */ template void submit(T* ptr) noexcept(false) { - IGarbage* garbage = new Garbage(ptr); + IGarbage* garbage = allocatedFor(new Garbage(ptr)); if (IGarbage* end = submittedEnd) { // 后续添加,可能存在线程竞争 while (end->next) end = end->next; // 理论上不会进入循环,但防止万一 end->next = garbage; diff --git a/main.cpp b/main.cpp index 9346221..a40cc84 100644 Binary files a/main.cpp and b/main.cpp differ diff --git a/utils.h b/utils.h index 562f9d6..e7c0eb4 100644 --- a/utils.h +++ b/utils.h @@ -170,7 +170,7 @@ bool AnywhereIterator::operator==(const AnywhereIteratorEnd& other) const template int AnywhereEditableList::pushCopy(T* value) noexcept { - T* nv = new T(*value); + T* nv = allocatedFor(new T(*value)); return pushNewed(nv); } @@ -191,7 +191,7 @@ int AnywhereEditableList::pushThis(T* value) noexcept { template int AnywhereEditableList::pushNewed(T* value) noexcept { const int ret = pushThis(value); - if (ret) delete value; + if (ret) delete deallocating(value); else value->managedByList = true; return ret; } @@ -205,6 +205,6 @@ int AnywhereEditableList::pop(T* value) noexcept { value->list = nullptr; value->next->prev = value->prev; value->prev->next = value->next; - if (value->managedByList) delete value; + if (value->managedByList) delete deallocating(value); Success(); } diff --git a/xWindows.h b/xWindows.h index 4755984..28bdde6 100644 Binary files a/xWindows.h and b/xWindows.h differ