Fix memleak, free TreeBuilder

This commit is contained in:
Artiom Di 2013-11-14 13:08:34 +02:00
parent d8c3772e35
commit 295ec8894c
1 changed files with 4 additions and 3 deletions

View File

@ -6,8 +6,8 @@ package git
*/
import "C"
import (
"unsafe"
"runtime"
"unsafe"
)
// Repository
@ -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