MCPcopy Create free account
hub / github.com/davisking/dlib / dealloc

Method dealloc

dlib/external/pybind11/include/pybind11/pybind11.h:1930–1946  ·  view source on GitHub ↗

Deallocates an instance; via holder, if constructed; otherwise via operator delete.

Source from the content-addressed store, hash-verified

1928
1929 /// Deallocates an instance; via holder, if constructed; otherwise via operator delete.
1930 static void dealloc(detail::value_and_holder &v_h) {
1931 // We could be deallocating because we are cleaning up after a Python exception.
1932 // If so, the Python error indicator will be set. We need to clear that before
1933 // running the destructor, in case the destructor code calls more Python.
1934 // If we don't, the Python API will exit with an exception, and pybind11 will
1935 // throw error_already_set from the C++ destructor which is forbidden and triggers
1936 // std::terminate().
1937 error_scope scope;
1938 if (v_h.holder_constructed()) {
1939 v_h.holder<holder_type>().~holder_type();
1940 v_h.set_holder_constructed(false);
1941 } else {
1942 detail::call_operator_delete(
1943 v_h.value_ptr<type>(), v_h.type->type_size, v_h.type->type_align);
1944 }
1945 v_h.value_ptr() = nullptr;
1946 }
1947
1948 static detail::function_record *get_function_record(handle h) {
1949 h = detail::get_function(h);

Callers 3

dispatcherMethod · 0.80
clear_instanceFunction · 0.80
constructFunction · 0.80

Calls 3

call_operator_deleteFunction · 0.85
holder_constructedMethod · 0.80

Tested by

no test coverage detected