Free reference resource allocated by libgit2 during go garbage collecting

This commit is contained in:
shinningstar 2015-06-08 22:36:31 +08:00
parent aefe85039e
commit 830e171463
1 changed files with 3 additions and 3 deletions

View File

@ -92,7 +92,7 @@ func (repo *Repository) NewBranchIterator(flags BranchType) (*BranchIterator, er
func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool, signature *Signature, msg string) (*Branch, error) { func (repo *Repository) CreateBranch(branchName string, target *Commit, force bool, signature *Signature, msg string) (*Branch, error) {
ref := new(Reference) var ptr *C.git_reference
cBranchName := C.CString(branchName) cBranchName := C.CString(branchName)
cForce := cbool(force) cForce := cbool(force)
@ -113,11 +113,11 @@ func (repo *Repository) CreateBranch(branchName string, target *Commit, force bo
runtime.LockOSThread() runtime.LockOSThread()
defer runtime.UnlockOSThread() defer runtime.UnlockOSThread()
ret := C.git_branch_create(&ref.ptr, repo.ptr, cBranchName, target.cast_ptr, cForce, cSignature, cmsg) ret := C.git_branch_create(&ptr, repo.ptr, cBranchName, target.cast_ptr, cForce, cSignature, cmsg)
if ret < 0 { if ret < 0 {
return nil, MakeGitError(ret) return nil, MakeGitError(ret)
} }
return ref.Branch(), nil return newReferenceFromC(ptr, repo).Branch(), nil
} }
func (b *Branch) Delete() error { func (b *Branch) Delete() error {