From 3148dab556f1f3534e2595db3234d2c4fede37e4 Mon Sep 17 00:00:00 2001 From: BLUELOVETH Date: Tue, 20 Jun 2023 19:24:37 +0800 Subject: [PATCH] fix https://github.com/blueloveTH/pocketpy/issues/94 --- src/gc.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) 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