MCPcopy Create free account
hub / github.com/pybind/pybind11 / tp_dealloc_impl

Function tp_dealloc_impl

include/pybind11/pybind11.h:1413–1423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1411
1412// This implementation needs the definition of `class cpp_function`.
1413inline void tp_dealloc_impl(PyObject *self) {
1414 // Save type before PyObject_Free invalidates self.
1415 auto *type = Py_TYPE(self);
1416 auto *py_func_rec = reinterpret_cast<function_record_PyObject *>(self);
1417 cpp_function::destruct(py_func_rec->cpp_func_rec);
1418 py_func_rec->cpp_func_rec = nullptr;
1419 // PyObject_New increments the heap type refcount and allocates via
1420 // PyObject_Malloc; balance both here
1421 PyObject_Free(self);
1422 Py_DECREF(type);
1423}
1424
1425PYBIND11_NAMESPACE_END(function_record_PyTypeObject_methods)
1426

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected