diff options
| author | Carlos Martín Nieto <[email protected]> | 2016-02-18 15:57:46 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <[email protected]> | 2016-02-18 15:57:46 +0100 |
| commit | ac719c675907a3185bdcebfe8329bde90d354aea (patch) | |
| tree | 3b14d189a436359d55f8f5f249d345d7836d2121 /odb.go | |
| parent | 4a9a59c6faef3a75fa9e0528cbc704cfd5c1edd9 (diff) | |
| parent | f05417aaba1a6a01d9533c38b4901bfc58002f49 (diff) | |
Merge branch 'master' into next
Diffstat (limited to 'odb.go')
| -rw-r--r-- | odb.go | 7 |
1 files changed, 5 insertions, 2 deletions
@@ -76,12 +76,15 @@ func (v *Odb) Exists(oid *Oid) bool { func (v *Odb) Write(data []byte, otype ObjectType) (oid *Oid, err error) { oid = new(Oid) - hdr := (*reflect.SliceHeader)(unsafe.Pointer(&data)) + var cptr unsafe.Pointer + if len(data) > 0 { + cptr = unsafe.Pointer(&data[0]) + } runtime.LockOSThread() defer runtime.UnlockOSThread() - ret := C.git_odb_write(oid.toC(), v.ptr, unsafe.Pointer(hdr.Data), C.size_t(hdr.Len), C.git_otype(otype)) + ret := C.git_odb_write(oid.toC(), v.ptr, cptr, C.size_t(len(data)), C.git_otype(otype)) if ret < 0 { return nil, MakeGitError(ret) |
