func (odb *Odb) Write(data []byte, form ObjectType) (*Oid, error) { oid := new(Oid) cdata := unsafe.Pointer(&data[0]) defer C.free(cdata) length := C.size_t(len(data)) ecode := C.git_odb_write(oid.git_oid, odb.git_odb, cdata, length, C.git_otype(form)) if ecode != git_SUCCESS { return nil, gitError() } return oid, nil }
func (v *Odb) Write(data []byte, otype ObjectType) (oid *Oid, err error) { oid = new(Oid) hdr := (*reflect.SliceHeader)(unsafe.Pointer(&data)) ret := C.git_odb_write(oid.toC(), v.ptr, unsafe.Pointer(hdr.Data), C.size_t(hdr.Len), C.git_otype(otype)) if ret < 0 { err = LastError() } return }
func (v *Odb) Write(data []byte, otype ObjectType) (oid *Oid, err error) { oid = new(Oid) hdr := (*reflect.SliceHeader)(unsafe.Pointer(&data)) 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)) if ret < 0 { return nil, MakeGitError(ret) } return oid, nil }
func (v *Odb) Write(data []byte, otype ObjectType) (oid *Oid, err error) { oid = new(Oid) 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, cptr, C.size_t(len(data)), C.git_otype(otype)) if ret < 0 { return nil, MakeGitError(ret) } return oid, nil }