summaryrefslogtreecommitdiff
path: root/stash.go
diff options
context:
space:
mode:
authorCalin Seciu <[email protected]>2016-02-20 14:34:29 +0200
committerCalin Seciu <[email protected]>2016-02-20 14:44:20 +0200
commitdc4409793db0205ce7c0783a10363d7d67aee674 (patch)
treebef161b931ba5bcf14f0a8c0c2ed0edc06203333 /stash.go
parent5191254a66ac049611fb16e4bb5f273aeb2ac322 (diff)
Remove Untrack() from free() function
https://github.com/libgit2/git2go/pull/257#discussion_r53443211
Diffstat (limited to 'stash.go')
-rw-r--r--stash.go12
1 files changed, 9 insertions, 3 deletions
diff --git a/stash.go b/stash.go
index 7a4fc93..8d8f984 100644
--- a/stash.go
+++ b/stash.go
@@ -182,12 +182,16 @@ func (opts *StashApplyOptions) toC() (
return
}
+// should be called after every call to toC() as deferred.
+func untrackStashApplyOptionsCallback(optsC *C.git_stash_apply_options) {
+ if optsC != nil && optsC.progress_payload != nil {
+ pointerHandles.Untrack(optsC.progress_payload)
+ }
+}
+
func freeStashApplyOptions(optsC *C.git_stash_apply_options) {
if optsC != nil {
freeCheckoutOpts(&optsC.checkout_options)
- if optsC.progress_payload != nil {
- pointerHandles.Untrack(optsC.progress_payload)
- }
}
}
@@ -217,6 +221,7 @@ func freeStashApplyOptions(optsC *C.git_stash_apply_options) {
// Error codes can be interogated with IsErrorCode(err, ErrNotFound).
func (c *StashCollection) Apply(index int, opts StashApplyOptions) error {
optsC, progressData := opts.toC()
+ defer untrackStashApplyOptionsCallback(optsC)
defer freeStashApplyOptions(optsC)
runtime.LockOSThread()
@@ -316,6 +321,7 @@ func (c *StashCollection) Drop(index int) error {
// state for the given index.
func (c *StashCollection) Pop(index int, opts StashApplyOptions) error {
optsC, progressData := opts.toC()
+ defer untrackStashApplyOptionsCallback(optsC)
defer freeStashApplyOptions(optsC)
runtime.LockOSThread()