We could also use the capsule's "context" to point to a C string "destructor:xmlFreeDoc" to explicitly indicate that the cleanup uses the default case. That should then avoid the copy in almost all cases.
We could also use the capsule's "context" to point to a C string "destructor: xmlFreeDoc" to explicitly indicate that the cleanup uses the default case. That should then avoid the copy in almost all cases.