free C string
This commit is contained in:
parent
8b39eb7953
commit
ebb657ce2f
10
blame.go
10
blame.go
|
@ -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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue