mirror of
https://github.com/exaloop/codon.git
synced 2025-06-03 15:03:52 +08:00
Fix allocation
This commit is contained in:
parent
e484bbe5c2
commit
fbd0105958
@ -2,7 +2,8 @@
|
|||||||
|
|
||||||
from internal.gc import (
|
from internal.gc import (
|
||||||
free, register_finalizer, seq_alloc,
|
free, register_finalizer, seq_alloc,
|
||||||
seq_alloc_atomic, seq_gc_add_roots, alloc_uncollectable
|
seq_alloc_atomic, seq_gc_add_roots, alloc_uncollectable,
|
||||||
|
alloc_atomic_uncollectable, atomic
|
||||||
)
|
)
|
||||||
|
|
||||||
@pure
|
@pure
|
||||||
|
@ -1897,8 +1897,12 @@ class _PyWrap:
|
|||||||
return cobj()
|
return cobj()
|
||||||
|
|
||||||
def wrap_to_py(o) -> cobj:
|
def wrap_to_py(o) -> cobj:
|
||||||
pytype = _PyWrap.py_type(type(o))
|
O = type(o)
|
||||||
obj = Ptr[PyWrapper[type(o)]](alloc_uncollectable(sizeof(type(o))))
|
P = PyWrapper[O]
|
||||||
|
sz = sizeof(P)
|
||||||
|
pytype = _PyWrap.py_type(O)
|
||||||
|
mem = alloc_atomic_uncollectable(sz) if atomic(O) else alloc_uncollectable(sz)
|
||||||
|
obj = Ptr[P](mem.as_byte())
|
||||||
obj[0] = PyWrapper(PyObject(1, pytype), o)
|
obj[0] = PyWrapper(PyObject(1, pytype), o)
|
||||||
return obj.as_byte()
|
return obj.as_byte()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user