I think I've addressed everything that was raised in review.
Some of the highlights:
- Callbacks should be freed reliably along all exit paths.
- There's a simple test of closure lifetimes.
- I've tried to use VALID|FREE in all the places where I'm confident
that it's safe and correct to do. There may be more places. Note
this is an optimization and shouldn't affect correctness.
- It's a bit difficult to use VALID|FREE when freeing the debug
callback (because context is not easily available) so I didn't make
that change.
Rich.