Esempio n. 1
0
def unicode_dealloc(space, py_obj):
    py_unicode = rffi.cast(PyUnicodeObject, py_obj)
    if py_unicode.c_str:
        lltype.free(py_unicode.c_str, flavor="raw")
    from pypy.module.cpyext.object import PyObject_dealloc
    if py_unicode.c_defenc:
        PyObject_dealloc(space, py_unicode.c_defenc)
    PyObject_dealloc(space, py_obj)
Esempio n. 2
0
def frame_dealloc(space, py_obj):
    py_frame = rffi.cast(PyFrameObject, py_obj)
    py_code = rffi.cast(PyObject, py_frame.c_f_code)
    Py_DecRef(space, py_code)
    Py_DecRef(space, py_frame.c_f_globals)
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 3
0
def string_dealloc(space, py_obj):
    """Frees allocated PyStringObject resources.
    """
    py_str = rffi.cast(PyStringObject, py_obj)
    if py_str.c_buffer:
        lltype.free(py_str.c_buffer, flavor="raw")
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 4
0
def unicode_dealloc(space, py_obj):
    py_unicode = rffi.cast(PyUnicodeObject, py_obj)
    if py_unicode.c_buffer:
        lltype.free(py_unicode.c_buffer, flavor="raw")
    if py_unicode.c_utf8buffer:
        lltype.free(py_unicode.c_utf8buffer, flavor="raw")
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 5
0
def buffer_dealloc(space, py_obj):
    py_buf = rffi.cast(PyBufferObject, py_obj)
    if py_buf.c_b_base:
        Py_DecRef(space, py_buf.c_b_base)
    else:
        rffi.free_charp(rffi.cast(rffi.CCHARP, py_buf.c_b_ptr))
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 6
0
def slice_dealloc(space, py_obj):
    """Frees allocated PyStringObject resources.
    """
    py_slice = rffi.cast(PySliceObject, py_obj)
    Py_DecRef(space, py_slice.c_start)
    Py_DecRef(space, py_slice.c_stop)
    Py_DecRef(space, py_slice.c_step)
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 7
0
def tuple_dealloc(space, py_obj):
    """Frees allocated PyTupleObject resources.
    """
    py_tup = rffi.cast(PyTupleObject, py_obj)
    p = py_tup.c_ob_item
    if p:
        for i in range(py_tup.c_ob_size):
            decref(space, p[i])
        lltype.free(p, flavor="raw")
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 8
0
def type_dealloc(space, obj):
    from pypy.module.cpyext.object import PyObject_dealloc
    obj_pto = rffi.cast(PyTypeObjectPtr, obj)
    base_pyo = rffi.cast(PyObject, obj_pto.c_tp_base)
    Py_DecRef(space, obj_pto.c_tp_bases)
    Py_DecRef(space, obj_pto.c_tp_mro)
    Py_DecRef(space, obj_pto.c_tp_cache) # let's do it like cpython
    Py_DecRef(space, obj_pto.c_tp_dict)
    if obj_pto.c_tp_flags & Py_TPFLAGS_HEAPTYPE:
        heaptype = rffi.cast(PyHeapTypeObject, obj)
        Py_DecRef(space, heaptype.c_ht_name)
        Py_DecRef(space, base_pyo)
        PyObject_dealloc(space, obj)
Esempio n. 9
0
def code_dealloc(space, py_obj):
    py_code = rffi.cast(PyCodeObject, py_obj)
    Py_DecRef(space, py_code.c_co_name)
    Py_DecRef(space, py_code.c_co_filename)
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 10
0
def function_dealloc(space, py_obj):
    py_func = rffi.cast(PyFunctionObject, py_obj)
    Py_DecRef(space, py_func.c_func_name)
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 11
0
def cfunction_dealloc(space, py_obj):
    py_func = rffi.cast(PyCFunctionObject, py_obj)
    Py_DecRef(space, py_func.c_m_self)
    Py_DecRef(space, py_func.c_m_module)
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)
Esempio n. 12
0
def traceback_dealloc(space, py_obj):
    py_traceback = rffi.cast(PyTracebackObject, py_obj)
    Py_DecRef(space, rffi.cast(PyObject, py_traceback.c_tb_next))
    Py_DecRef(space, rffi.cast(PyObject, py_traceback.c_tb_frame))
    from pypy.module.cpyext.object import PyObject_dealloc
    PyObject_dealloc(space, py_obj)