diff options
| author | Jesse Ezell <[email protected]> | 2014-04-04 00:22:42 -0700 |
|---|---|---|
| committer | Jesse Ezell <[email protected]> | 2014-04-04 00:22:42 -0700 |
| commit | 864c57f554821143b6298e3b927d362d996a32c2 (patch) | |
| tree | f4f863d218f454a319cf14d925e058cc6a069eae /merge.go | |
| parent | 0b48ba2224ec41dfc10a379ce1b7bb86441cc432 (diff) | |
| parent | 9cd1d129bcd567ef65137783a603f8d898d8d933 (diff) | |
merge latest, copy merge bytes to go array
Diffstat (limited to 'merge.go')
| -rw-r--r-- | merge.go | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -225,9 +225,8 @@ type MergeFileResult struct { Automergeable bool Path string Mode uint - Contents []byte // Contents of file, will be invalid after Free - - ptr *C.git_merge_file_result + Contents []byte + ptr *C.git_merge_file_result } func newMergeFileResultFromC(c *C.git_merge_file_result) *MergeFileResult { @@ -236,11 +235,14 @@ func newMergeFileResultFromC(c *C.git_merge_file_result) *MergeFileResult { path = C.GoString(c.path) } + originalBytes := C.GoBytes(unsafe.Pointer(c.ptr), C.int(c.len)) + gobytes := make([]byte, len(originalBytes)) + copy(gobytes, originalBytes) r := &MergeFileResult{ Automergeable: c.automergeable != 0, Path: path, Mode: uint(c.mode), - Contents: C.GoBytes(unsafe.Pointer(c.ptr), C.int(c.len)), + Contents: gobytes, ptr: c, } |
