From 58334cf60441bd713b8fd990e30e0580b97bf3ae Mon Sep 17 00:00:00 2001 From: Carlos Martín Nieto Date: Fri, 7 Jul 2017 23:45:09 +0200 Subject: First round of mass keep-alive additions --- commit.go | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'commit.go') diff --git a/commit.go b/commit.go index 3ccb5da..5aa5f25 100644 --- a/commit.go +++ b/commit.go @@ -77,7 +77,7 @@ func (c *Commit) Tree() (*Tree, error) { func (c *Commit) TreeId() *Oid { ret := newOidFromC(C.git_commit_tree_id(c.cast_ptr)) runtime.KeepAlive(c) - return c + return ret } func (c *Commit) Author() *Signature { @@ -101,15 +101,21 @@ func (c *Commit) Parent(n uint) *Commit { return nil } - return allocCommit(cobj, c.repo) + parent := allocCommit(cobj, c.repo) + runtime.KeepAlive(c) + return parent } func (c *Commit) ParentId(n uint) *Oid { - return newOidFromC(C.git_commit_parent_id(c.cast_ptr, C.uint(n))) + ret := newOidFromC(C.git_commit_parent_id(c.cast_ptr, C.uint(n))) + runtime.KeepAlive(c) + return ret } func (c *Commit) ParentCount() uint { - return uint(C.git_commit_parentcount(c.cast_ptr)) + ret := uint(C.git_commit_parentcount(c.cast_ptr)) + runtime.KeepAlive(c) + return ret } func (c *Commit) Amend(refname string, author, committer *Signature, message string, tree *Tree) (*Oid, error) { @@ -142,6 +148,9 @@ func (c *Commit) Amend(refname string, author, committer *Signature, message str oid := new(Oid) cerr := C.git_commit_amend(oid.toC(), c.cast_ptr, cref, authorSig, committerSig, nil, cmsg, tree.cast_ptr) + runtime.KeepAlive(oid) + runtime.KeepAlive(c) + runtime.KeepAlive(tree) if cerr < 0 { return nil, MakeGitError(cerr) } -- cgit v1.2.3