static void __Pyx_Generator_dealloc(PyObject *self) { __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; PyObject_GC_UnTrack(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); if (gen->resume_label > 0) { // Generator is paused, so we need to close PyObject_GC_Track(self); #if PY_VERSION_HEX >= 0x030400a1 if (PyObject_CallFinalizerFromDealloc(self)) #else Py_TYPE(gen)->tp_del(self); if (self->ob_refcnt > 0) #endif { // resurrected. :( return; } PyObject_GC_UnTrack(self); } __Pyx_Generator_clear(self); PyObject_GC_Del(gen); }
static void mmap_object_dealloc(mmap_object *m_obj) { #ifdef MS_WINDOWS if (m_obj->data != NULL) UnmapViewOfFile (m_obj->data); if (m_obj->map_handle != NULL) CloseHandle (m_obj->map_handle); if (m_obj->file_handle != INVALID_HANDLE_VALUE) CloseHandle (m_obj->file_handle); if (m_obj->tagname) PyMem_Free(m_obj->tagname); #endif /* MS_WINDOWS */ #ifdef UNIX if (m_obj->fd >= 0) (void) close(m_obj->fd); if (m_obj->data!=NULL) { munmap(m_obj->data, m_obj->size); } #endif /* UNIX */ if (m_obj->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) m_obj); Py_TYPE(m_obj)->tp_free((PyObject*)m_obj); }
static void code_dealloc(PyCodeObject *co) { if (co->co_extra != NULL) { PyInterpreterState *interp = PyThreadState_Get()->interp; _PyCodeObjectExtra *co_extra = co->co_extra; for (Py_ssize_t i = 0; i < co_extra->ce_size; i++) { freefunc free_extra = interp->co_extra_freefuncs[i]; if (free_extra != NULL) { free_extra(co_extra->ce_extras[i]); } } PyMem_Free(co_extra); } Py_XDECREF(co->co_code); Py_XDECREF(co->co_consts); Py_XDECREF(co->co_names); Py_XDECREF(co->co_varnames); Py_XDECREF(co->co_freevars); Py_XDECREF(co->co_cellvars); Py_XDECREF(co->co_filename); Py_XDECREF(co->co_name); Py_XDECREF(co->co_lnotab); if (co->co_cell2arg != NULL) PyMem_FREE(co->co_cell2arg); if (co->co_zombieframe != NULL) PyObject_GC_Del(co->co_zombieframe); if (co->co_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject*)co); PyObject_DEL(co); }
static int Params_clear(ParamsObject *self) { if (self->weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject*)self); } Py_CLEAR(self->py_lp); return 0; }
static void connection_dealloc(PyObject* obj) { connectionObject *self = (connectionObject *)obj; /* Make sure to untrack the connection before calling conn_close, which may * allow a different thread to try and dealloc the connection again, * resulting in a double-free segfault (ticket #166). */ PyObject_GC_UnTrack(self); conn_close(self); if (self->weakreflist) { PyObject_ClearWeakRefs(obj); } conn_notice_clean(self); PyMem_Free(self->dsn); PyMem_Free(self->encoding); if (self->critical) free(self->critical); if (self->cancel) PQfreeCancel(self->cancel); connection_clear(self); pthread_mutex_destroy(&(self->lock)); Dprintf("connection_dealloc: deleted connection object at %p, refcnt = " FORMAT_CODE_PY_SSIZE_T, obj, Py_REFCNT(obj) ); Py_TYPE(obj)->tp_free(obj); }
static void Handle_tp_dealloc(Handle *self) { ASSERT(self->uv_handle); if (self->initialized && !uv_is_closing(self->uv_handle)) { uv_close(self->uv_handle, on_handle_dealloc_close); ASSERT(uv_is_closing(self->uv_handle)); /* resurrect the Python object until the close callback is called */ Py_INCREF(self); resurrect_object((PyObject *)self); return; } else { /* There are a few cases why the code will take this path: * - A subclass of a handle didn't call it's parent's __init__ * - Aclosed handle is deallocated. Refcount is increased in close(), * so it's guaranteed that if we arrived here and the user had called close(), * the callback was already executed. * - A handle goes out of scope and it's closed here in tp_dealloc and resurrected. * Once it's deallocated again it will take this path because the handle is now * closed. */ ; } if (self->weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *)self); } Py_TYPE(self)->tp_clear((PyObject *)self); Py_TYPE(self)->tp_free((PyObject *)self); }
/** * \param self A PyObjectPlus_Proxy */ void PyObjectPlus::py_base_dealloc(PyObject *self) // python wrapper { #ifdef USE_WEAKREFS if (BGE_PROXY_WKREF(self) != NULL) PyObject_ClearWeakRefs((PyObject *) self); #endif if (BGE_PROXY_PYREF(self)) { PyObjectPlus *self_plus= BGE_PROXY_REF(self); if (self_plus) { if (BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */ self_plus->m_proxy = NULL; /* Need this to stop ~PyObjectPlus from decrefing m_proxy otherwise its decref'd twice and py-debug crashes */ delete self_plus; } BGE_PROXY_REF(self)= NULL; // not really needed } // the generic pointer is not deleted directly, only through self_plus BGE_PROXY_PTR(self)= NULL; // not really needed } else { void *ptr= BGE_PROXY_PTR(self); if (ptr) { if (BGE_PROXY_PYOWNS(self)) { /* Does python own this?, then delete it */ // generic structure owned by python MUST be created though MEM_alloc MEM_freeN(ptr); } BGE_PROXY_PTR(self)= NULL; // not really needed } } #if 0 /* is ok normally but not for subtyping, use tp_free instead. */ PyObject_DEL( self ); #else Py_TYPE(self)->tp_free(self); #endif };
static void tasklet_dealloc(PyTaskletObject *t) { if (tasklet_has_c_stack(t)) { /* * we want to cleanly kill the tasklet in the case it * was forgotten. One way would be to resurrect it, * but this is quite ugly with many ifdefs, see * classobject/typeobject. * Well, we do it. */ if (slp_resurrect_and_kill((PyObject *) t, kill_finally)) { /* the beast has grown new references */ return; } } tasklet_clear_frames(t); if (t->tsk_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)t); if (t->cstate != NULL) { assert(t->cstate->task != t || t->cstate->ob_size == 0); Py_DECREF(t->cstate); } Py_DECREF(t->tempval); Py_XDECREF(t->def_globals); t->ob_type->tp_free((PyObject*)t); }
void WeakSet_dealloc(WeakSet *self){ if (self->in_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) self); Py_XDECREF(self->set); Py_XDECREF(self->selfref); self->ob_type->tp_free((PyObject*)self); }
static int sllist_clear_refs(SLListObject* self) { PyObject* node = self->first; if (self->weakref_list != NULL) PyObject_ClearWeakRefs((PyObject*)self); self->first = NULL; self->last = NULL; self->weakref_list = NULL; if (node != NULL) { while (node != Py_None) { PyObject* next_node = ((SLListNodeObject*)node)->next; ((SLListNodeObject*)node)->next = Py_None; Py_DECREF(node); node = next_node; } } Py_DECREF(Py_None); return 0; }
static int Bar_clear(BarObject *self) { if (self->weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject*)self); } Py_CLEAR(self->py_bc); return 0; }
static void __Pyx_Generator_dealloc(PyObject *self) { __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self; PyObject_GC_UnTrack(gen); if (gen->gi_weakreflist != NULL) PyObject_ClearWeakRefs(self); PyObject_GC_Track(self); if (gen->resume_label > 0) { /* Generator is paused, so we need to close */ Py_TYPE(gen)->tp_del(self); if (self->ob_refcnt > 0) return; /* resurrected. :( */ } PyObject_GC_UnTrack(self); Py_CLEAR(gen->closure); Py_CLEAR(gen->classobj); Py_CLEAR(gen->exc_type); Py_CLEAR(gen->exc_value); Py_CLEAR(gen->exc_traceback); PyObject_GC_Del(gen); }
static void compose_dealloc(PyComposeObject* self) { PyObject_GC_UnTrack(self); if(self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject*)self); compose_clear(self); PyObject_GC_Del(self); }
static void eConsolePy_dealloc(eConsolePy* self) { if (self->in_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) self); eConsolePy_clear(self); self->cont->Release(); self->ob_type->tp_free((PyObject*)self); }
static void dbgbp_dealloc(PyDebugBreakpointObject *self) { if (self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)self); if (self->bp) self->bp = NULL; Py_TYPE(self)->tp_free((PyObject *)self); }
static void CapObject_dealloc(CapObject* self) { if (self->__weakref__ != NULL) PyObject_ClearWeakRefs((PyObject *) self); CapObject_clear(self); self->ob_type->tp_free((PyObject*)self); }
static void func_dealloc(PyFunctionObject *op) { _PyObject_GC_UNTRACK(op); if (op->func_weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *) op); } (void)func_clear(op); PyObject_GC_Del(op); }
static int TDI_SoupEncoderType_clear(tdi_soup_encoder_t *self) { if (self->weakreflist) PyObject_ClearWeakRefs((PyObject *)self); Py_CLEAR(self->encoding); return 0; }
static void Bar_dealloc(BarObject *self) { #ifdef USE_BAR_GC Bar_clear(self); #else if (self->weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject*)self); } Py_DECREF(self->py_bc); #endif Py_TYPE(self)->tp_free((PyObject*)self); }
/** * \ingroup python_interface_vertexseq * \brief Deallocates a Python representation of a given vertex sequence object */ void igraphmodule_VertexSeq_dealloc(igraphmodule_VertexSeqObject* self) { if (self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) self); if (self->gref) { igraph_vs_destroy(&self->vs); Py_DECREF(self->gref); self->gref=0; } Py_TYPE(self)->tp_free((PyObject*)self); RC_DEALLOC("VertexSeq", self); }
static void s_dealloc(PyStructObject *s) { if (s->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)s); if (s->s_codes != NULL) { PyMem_FREE(s->s_codes); } Py_XDECREF(s->s_format); Py_TYPE(s)->tp_free((PyObject *)s); }
static void Nuitka_Function_tp_dealloc( Nuitka_FunctionObject *function ) { #ifndef __NUITKA_NO_ASSERT__ // Save the current exception, if any, we must to not corrupt it. PyObject *save_exception_type, *save_exception_value; PyTracebackObject *save_exception_tb; FETCH_ERROR_OCCURRED( &save_exception_type, &save_exception_value, &save_exception_tb ); RESTORE_ERROR_OCCURRED( save_exception_type, save_exception_value, save_exception_tb ); #endif Nuitka_GC_UnTrack( function ); if ( function->m_weakrefs != NULL ) { PyObject_ClearWeakRefs( (PyObject *)function ); } Py_DECREF( function->m_name ); #if PYTHON_VERSION >= 330 Py_DECREF( function->m_qualname ); #endif // These may actually re-surrect the object, not? Py_XDECREF( function->m_dict ); Py_DECREF( function->m_defaults ); Py_DECREF( function->m_doc ); #if PYTHON_VERSION >= 300 Py_DECREF( function->m_kwdefaults ); Py_DECREF( function->m_annotations ); #endif if ( function->m_closure ) { for( Py_ssize_t i = 0; i < function->m_closure_given; i++ ) { Py_DECREF( function->m_closure[i] ); } free( function->m_closure ); } PyObject_GC_Del( function ); #ifndef __NUITKA_NO_ASSERT__ PyThreadState *tstate = PyThreadState_GET(); assert( tstate->curexc_type == save_exception_type ); assert( tstate->curexc_value == save_exception_value ); assert( (PyTracebackObject *)tstate->curexc_traceback == save_exception_tb ); #endif }
/* lifetimelock object internals */ static void _lifelock_dealloc (PyObject* self) { PyLifetimeLock* lifelock = (PyLifetimeLock*) self; if (lifelock->weakrefs) PyObject_ClearWeakRefs (self); PySurface_UnlockBy (lifelock->surface, lifelock->lockobj); Py_DECREF (lifelock->surface); PyObject_DEL (self); }
static void libattk_dealloc(attack_class_st *self) { #ifdef DEBUG printf("libattk_dealloc START\n"); #endif /* TODO: Cleanup */ if (self->in_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)self); libattk_clear(self); self->ob_type->tp_free((PyObject *)self); }
static void array_dealloc(PyArrayObject *self) { _array_dealloc_buffer_info(self); if (self->weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject *)self); } if (self->base) { /* * UPDATEIFCOPY means that base points to an * array that should be updated with the contents * of this array upon destruction. * self->base->flags must have been WRITEABLE * (checked previously) and it was locked here * thus, unlock it. */ if (self->flags & UPDATEIFCOPY) { ((PyArrayObject *)self->base)->flags |= WRITEABLE; Py_INCREF(self); /* hold on to self in next call */ if (PyArray_CopyAnyInto((PyArrayObject *)self->base, self) < 0) { PyErr_Print(); PyErr_Clear(); } /* * Don't need to DECREF -- because we are deleting *self already... */ } /* * In any case base is pointing to something that we need * to DECREF -- either a view or a buffer object */ Py_DECREF(self->base); } if ((self->flags & OWNDATA) && self->data) { /* Free internal references if an Object array */ if (PyDataType_FLAGCHK(self->descr, NPY_ITEM_REFCOUNT)) { Py_INCREF(self); /*hold on to self */ PyArray_XDECREF(self); /* * Don't need to DECREF -- because we are deleting * self already... */ } PyDataMem_FREE(self->data); } PyDimMem_FREE(self->dimensions); Py_DECREF(self->descr); Py_TYPE(self)->tp_free((PyObject *)self); }
static void partial_dealloc(partialobject *pto) { PyObject_GC_UnTrack(pto); if (pto->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *) pto); Py_XDECREF(pto->fn); Py_XDECREF(pto->args); Py_XDECREF(pto->kw); Py_XDECREF(pto->dict); Py_TYPE(pto)->tp_free(pto); }
static void CP_dealloc(ProxyObject *self) { if (self->po_weaklist != NULL) PyObject_ClearWeakRefs((PyObject *)self); CLEAR(self->proxy_object); CLEAR(self->__parent__); CLEAR(self->__name__); cPersistenceCAPI->pertype->tp_dealloc((PyObject*)self); }
static int LPX_clear(LPXObject *self) { if (self->weakreflist != NULL) { PyObject_ClearWeakRefs((PyObject*)self); } Py_CLEAR(self->rows); Py_CLEAR(self->cols); Py_CLEAR(self->obj); #ifdef USEPARAMS Py_CLEAR(self->params); #endif return 0; }
static void dbgadv_dealloc(PyDebugAdvancedObject *self) { if (self->weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)self); if (self->adv != NULL) { self->adv->Release(); self->adv = NULL; } Py_TYPE(self)->tp_free((PyObject *)self); }
static void Nuitka_Generator_tp_dealloc( struct Nuitka_GeneratorObject *generator ) { // Revive temporarily. assert( Py_REFCNT( generator ) == 0 ); Py_REFCNT( generator ) = 1; // Save the current exception, if any, we must preserve it. PyObject *save_exception_type, *save_exception_value; PyTracebackObject *save_exception_tb; FETCH_ERROR_OCCURRED( &save_exception_type, &save_exception_value, &save_exception_tb ); if ( generator->m_status == status_Running ) { PyObject *close_result = Nuitka_Generator_close( generator, NULL ); if (unlikely( close_result == NULL )) { PyErr_WriteUnraisable( (PyObject *)generator ); } else { Py_DECREF( close_result ); } } Nuitka_Generator_release_closure( generator ); Py_XDECREF( generator->m_frame ); assert( Py_REFCNT( generator ) == 1 ); Py_REFCNT( generator ) = 0; releaseFiber( &generator->m_yielder_context ); // Now it is safe to release references and memory for it. Nuitka_GC_UnTrack( generator ); if ( generator->m_weakrefs != NULL ) { PyObject_ClearWeakRefs( (PyObject *)generator ); assert( !ERROR_OCCURRED() ); } Py_DECREF( generator->m_name ); #if PYTHON_VERSION >= 350 Py_DECREF( generator->m_qualname ); #endif PyObject_GC_Del( generator ); RESTORE_ERROR_OCCURRED( save_exception_type, save_exception_value, save_exception_tb ); }