diff options
| author | Quinn Slack <[email protected]> | 2014-11-18 04:58:23 -0800 |
|---|---|---|
| committer | Quinn Slack <[email protected]> | 2014-11-18 04:58:23 -0800 |
| commit | ebb657ce2f8fdeac32dda6fb88d3a20548e034a7 (patch) | |
| tree | ddaae20ccc5e6990d8b026de4e2f92e61894f8ed | |
| parent | 8b39eb795340dff00f16f93d6e9d154fabc98b14 (diff) | |
free C string
| -rw-r--r-- | blame.go | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -4,7 +4,10 @@ package git #include <git2.h> */ import "C" -import "runtime" +import ( + "runtime" + "unsafe" +) type BlameOptions struct { Flags BlameOptionsFlag @@ -66,10 +69,13 @@ func (v *Repository) BlameFile(path string, opts *BlameOptions) (*Blame, error) } } + cpath := C.CString(path) + defer C.free(unsafe.Pointer(cpath)) + runtime.LockOSThread() defer runtime.UnlockOSThread() - ecode := C.git_blame_file(&blamePtr, v.ptr, C.CString(path), copts) + ecode := C.git_blame_file(&blamePtr, v.ptr, cpath, copts) if ecode < 0 { return nil, MakeGitError(ecode) } |
