diff options
| author | Carlos MartÃn Nieto <[email protected]> | 2017-07-08 16:51:22 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2017-07-08 16:51:22 +0200 |
| commit | 08db2e2c167404c5ed9be0fc1c995e41bad479bb (patch) | |
| tree | 4a9c1357f3682d4134318e73ef85aa172cbfbd48 /object.go | |
| parent | 29c0b730076fe402c22ea3e3a11a7ed541663637 (diff) | |
| parent | 55a1096141519a1f380d0702671cfe9bf90ec435 (diff) | |
Merge pull request #393 from libgit2/cmn/keepalive-all-the-things
KeepAlive all the things
Diffstat (limited to 'object.go')
| -rw-r--r-- | object.go | 21 |
1 files changed, 16 insertions, 5 deletions
@@ -46,7 +46,9 @@ func (t ObjectType) String() string { } func (o *Object) Id() *Oid { - return newOidFromC(C.git_object_id(o.ptr)) + ret := newOidFromC(C.git_object_id(o.ptr)) + runtime.KeepAlive(o) + return ret } func (o *Object) ShortId() (string, error) { @@ -56,6 +58,7 @@ func (o *Object) ShortId() (string, error) { defer runtime.UnlockOSThread() ecode := C.git_object_short_id(&resultBuf, o.ptr) + runtime.KeepAlive(o) if ecode < 0 { return "", MakeGitError(ecode) } @@ -64,15 +67,19 @@ func (o *Object) ShortId() (string, error) { } func (o *Object) Type() ObjectType { - return ObjectType(C.git_object_type(o.ptr)) + ret := ObjectType(C.git_object_type(o.ptr)) + runtime.KeepAlive(o) + return ret } // Owner returns a weak reference to the repository which owns this // object. This won't keep the underlying repository alive. func (o *Object) Owner() *Repository { - return &Repository{ + ret := &Repository{ ptr: C.git_object_owner(o.ptr), } + runtime.KeepAlive(o) + return ret } func dupObject(obj *Object, kind ObjectType) (*C.git_object, error) { @@ -85,7 +92,9 @@ func dupObject(obj *Object, kind ObjectType) (*C.git_object, error) { runtime.LockOSThread() defer runtime.UnlockOSThread() - if err := C.git_object_dup(&cobj, obj.ptr); err < 0 { + err := C.git_object_dup(&cobj, obj.ptr) + runtime.KeepAlive(obj) + if err < 0 { return nil, MakeGitError(err) } @@ -203,7 +212,9 @@ func (o *Object) Peel(t ObjectType) (*Object, error) { runtime.LockOSThread() defer runtime.UnlockOSThread() - if err := C.git_object_peel(&cobj, o.ptr, C.git_otype(t)); err < 0 { + err := C.git_object_peel(&cobj, o.ptr, C.git_otype(t)) + runtime.KeepAlive(o) + if err < 0 { return nil, MakeGitError(err) } |
