diff options
| author | Artiom Di <[email protected]> | 2013-11-14 13:08:34 +0200 |
|---|---|---|
| committer | Artiom Di <[email protected]> | 2013-11-14 13:08:34 +0200 |
| commit | 295ec8894c0e96330a106d4854bea5c1e9d37f20 (patch) | |
| tree | 6e795c302818bcf2a6fd560524f4ab31f31f103f | |
| parent | d8c3772e350f387bb55b74dc1d654d69bd66b69a (diff) | |
Fix memleak, free TreeBuilder
| -rw-r--r-- | repository.go | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/repository.go b/repository.go index 34df0aa..3ba3e5e 100644 --- a/repository.go +++ b/repository.go @@ -6,8 +6,8 @@ package git */ import "C" import ( - "unsafe" "runtime" + "unsafe" ) // Repository @@ -180,7 +180,7 @@ func (v *Repository) CreateCommit( var cparents []*C.git_commit = nil var parentsarg **C.git_commit = nil - nparents:= len(parents) + nparents := len(parents) if nparents > 0 { cparents = make([]*C.git_commit, nparents) for i, v := range parents { @@ -226,7 +226,7 @@ func (repo *Repository) Path() string { return C.GoString(C.git_repository_path(repo.ptr)) } -func (repo *Repository) IsBare() (bool) { +func (repo *Repository) IsBare() bool { return C.git_repository_is_bare(repo.ptr) != 0 } @@ -249,6 +249,7 @@ func (v *Repository) TreeBuilder() (*TreeBuilder, error) { if ret := C.git_treebuilder_create(&bld.ptr, nil); ret < 0 { return nil, LastError() } + runtime.SetFinalizer(bld, (*TreeBuilder).Free) bld.repo = v return bld, nil |
