diff options
| author | Vicent Martà <[email protected]> | 2013-11-18 07:24:37 -0800 |
|---|---|---|
| committer | Vicent Martà <[email protected]> | 2013-11-18 07:24:37 -0800 |
| commit | 625ffd022e2c39f3820543cc1239deeb21837266 (patch) | |
| tree | d82a9bc90cb9198ff2f9d1cb893eb530387fcde9 /commit.go | |
| parent | d8c3772e350f387bb55b74dc1d654d69bd66b69a (diff) | |
| parent | 5e30c192e9f7219322887da7252c344d5be1ec05 (diff) | |
Merge pull request #47 from kron4eg/tree_builder_mem_leak
Fix memleak, TreeBuilder, Config and Parent commit
Diffstat (limited to 'commit.go')
| -rw-r--r-- | commit.go | 13 |
1 files changed, 7 insertions, 6 deletions
@@ -9,8 +9,8 @@ extern int _go_git_treewalk(git_tree *tree, git_treewalk_mode mode, void *ptr); import "C" import ( - "unsafe" "time" + "unsafe" ) // Commit @@ -48,12 +48,13 @@ func (c Commit) Committer() *Signature { } func (c *Commit) Parent(n uint) *Commit { - par := &Commit{} - ret := C.git_commit_parent(&par.ptr, c.ptr, C.uint(n)) + var cobj *C.git_object + ret := C.git_commit_parent(&cobj, c.ptr, C.uint(n)) if ret != 0 { return nil } - return par + + return allocObject(cobj).(*Commit) } func (c *Commit) ParentId(n uint) *Oid { @@ -85,10 +86,10 @@ func newSignatureFromC(sig *C.git_signature) *Signature { // the offset in mintes, which is what git wants func (v *Signature) Offset() int { _, offset := v.When.Zone() - return offset/60 + return offset / 60 } -func (sig *Signature) toC() (*C.git_signature) { +func (sig *Signature) toC() *C.git_signature { var out *C.git_signature name := C.CString(sig.Name) |
