diff options
| author | Carlos Martín Nieto <[email protected]> | 2013-03-06 01:43:48 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2013-03-06 01:47:53 +0100 |
| commit | d43561fbf711896f5ce33f409c6000946416a82b (patch) | |
| tree | d4494ed38a76fa9c69f4fc00513340ff0096f980 /commit.go | |
| parent | 2885e3fe0cc403514d0ade13bae5f430b2e9252e (diff) | |
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.
Diffstat (limited to 'commit.go')
| -rw-r--r-- | commit.go | 3 |
1 files changed, 3 insertions, 0 deletions
@@ -9,6 +9,7 @@ extern int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr); import "C" import ( + "runtime" "time" ) @@ -32,6 +33,8 @@ func (c *Commit) Tree() (*Tree, error) { if err < 0 { return nil, LastError() } + + runtime.SetFinalizer(tree, (*Tree).Free) return tree, nil } |
