mirror of
https://github.com/pocketpy/pocketpy
synced 2025-10-20 11:30:18 +00:00
This commit is contained in:
parent
ae4057e457
commit
3148dab556
12
src/gc.h
12
src/gc.h
@ -40,7 +40,12 @@ struct ManagedHeap{
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
PyObject* gcnew(Type type, T&& val){
|
PyObject* gcnew(Type type, T&& val){
|
||||||
using __T = Py_<std::decay_t<T>>;
|
using __T = Py_<std::decay_t<T>>;
|
||||||
|
#if _WIN32
|
||||||
|
// https://github.com/blueloveTH/pocketpy/issues/94#issuecomment-1594784476
|
||||||
|
PyObject* obj = new(pool64.alloc<__T>()) Py_<std::decay_t<T>>(type, std::forward<T>(val));
|
||||||
|
#else
|
||||||
PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward<T>(val));
|
PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward<T>(val));
|
||||||
|
#endif
|
||||||
gen.push_back(obj);
|
gen.push_back(obj);
|
||||||
gc_counter++;
|
gc_counter++;
|
||||||
return obj;
|
return obj;
|
||||||
@ -49,7 +54,12 @@ struct ManagedHeap{
|
|||||||
template<typename T>
|
template<typename T>
|
||||||
PyObject* _new(Type type, T&& val){
|
PyObject* _new(Type type, T&& val){
|
||||||
using __T = Py_<std::decay_t<T>>;
|
using __T = Py_<std::decay_t<T>>;
|
||||||
|
#if _WIN32
|
||||||
|
// https://github.com/blueloveTH/pocketpy/issues/94#issuecomment-1594784476
|
||||||
|
PyObject* obj = new(pool64.alloc<__T>()) Py_<std::decay_t<T>>(type, std::forward<T>(val));
|
||||||
|
#else
|
||||||
PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward<T>(val));
|
PyObject* obj = new(pool64.alloc<__T>()) __T(type, std::forward<T>(val));
|
||||||
|
#endif
|
||||||
obj->gc.enabled = false;
|
obj->gc.enabled = false;
|
||||||
_no_gc.push_back(obj);
|
_no_gc.push_back(obj);
|
||||||
return obj;
|
return obj;
|
||||||
@ -121,4 +131,4 @@ inline void FuncDecl::_gc_mark() const{
|
|||||||
for(int i=0; i<kwargs.size(); i++) OBJ_MARK(kwargs[i].value);
|
for(int i=0; i<kwargs.size(); i++) OBJ_MARK(kwargs[i].value);
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace pkpy
|
} // namespace pkpy
|
||||||
|
Loading…
x
Reference in New Issue
Block a user