libgit2/git2go — pull request #3 by carlosmn (2013-03-06 00:57:45+00:00)
Title: Free Git objects via finalizers or manually

Provide a manual way of freeing objects, but set finalizers for them
in case the user does not want to worry about memory management, which
would be useful for commits or trees, which sare typically small.

When the objects are freed manually, the finalizer is unset to avoid
double-freeing, mimicking what the go runtime does.

---
This is what I was saying earlier. Through some magic that I can't quite remember, doing the `(*Type).Free` thing lets us have the same function for both manual and automatic freeing. There's bound to be some cost to calling into the `runtime` package. Though unlikely, if this becomes a problem, we could look into setting the pointer to `nil` in `Free()` and exit if it's already `nil`, like we do in C. But I think we'll cross that bridge when we get to it.