RFC: Revamp pdfdetach implementation to avoid repeating code paths and manual resource management.
Did this since we went there today and the fixes had to be applied three times. Not completely sure whether this is really worth it hence the RFC tag, but the result is indeed simpler IMHO. But there are also funny things in there, like using
unique_ptr to decrement a reference count or the doubly nested lambda to factor out the code blocks without creating file level helper functions.