[C++-sig] instance_holder::uninstall

Tim Prepscius timprepscius at gmail.com
Tue Jan 27 18:24:09 CET 2009

Does this look about right?  Perhaps this should be added to the
standard installation.
Necessary for forcing disconnects from python objects on the c++ side...

// Uninstall the instance data for a C++ object from a Python instance
// object.
void instance_holder::uninstall(PyObject* self) throw()
	assert(self->ob_type->ob_type == &class_metatype_object);
	instance_holder **chain = &(((objects::instance<>*)self)->objects);

	// iterate through, looking for the pointer that points to this
	while ( *chain && *chain != this )
		chain = &((*chain)->m_next);

	// set that pointer to point to the m_next
	if (*chain)
		*chain = m_next;

	m_next = 0;

More information about the Cplusplus-sig mailing list