From ebb657ce2f8fdeac32dda6fb88d3a20548e034a7 Mon Sep 17 00:00:00 2001 From: Quinn Slack Date: Tue, 18 Nov 2014 04:58:23 -0800 Subject: free C string --- blame.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/blame.go b/blame.go index 55100a4..cd5665a 100644 --- a/blame.go +++ b/blame.go @@ -4,7 +4,10 @@ package git #include */ 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) } -- cgit v1.2.3