diff --git a/src/gc.h b/src/gc.h index edd56140..d7db4d74 100644 --- a/src/gc.h +++ b/src/gc.h @@ -40,7 +40,12 @@ struct ManagedHeap{ template PyObject* gcnew(Type type, T&& val){ using __T = Py_>; +#if _WIN32 + // https://github.com/blueloveTH/pocketpy/issues/94#issuecomment-1594784476 + PyObject* obj = new(pool64.alloc<__T>()) Py_>(type, std::forward(val)); +#else PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward(val)); +#endif gen.push_back(obj); gc_counter++; return obj; @@ -49,7 +54,12 @@ struct ManagedHeap{ template PyObject* _new(Type type, T&& val){ using __T = Py_>; +#if _WIN32 + // https://github.com/blueloveTH/pocketpy/issues/94#issuecomment-1594784476 + PyObject* obj = new(pool64.alloc<__T>()) Py_>(type, std::forward(val)); +#else PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward(val)); +#endif obj->gc.enabled = false; _no_gc.push_back(obj); return obj; @@ -121,4 +131,4 @@ inline void FuncDecl::_gc_mark() const{ for(int i=0; i