Implement io.Writer
(p []byte)
| 114 | |
| 115 | // Implement io.Writer |
| 116 | func (stream *BlobWriteStream) Write(p []byte) (int, error) { |
| 117 | header := (*reflect.SliceHeader)(unsafe.Pointer(&p)) |
| 118 | ptr := (*C.char)(unsafe.Pointer(header.Data)) |
| 119 | size := C.size_t(header.Len) |
| 120 | |
| 121 | runtime.LockOSThread() |
| 122 | defer runtime.UnlockOSThread() |
| 123 | |
| 124 | ecode := C._go_git_writestream_write(stream.ptr, ptr, size) |
| 125 | runtime.KeepAlive(stream) |
| 126 | if ecode < 0 { |
| 127 | return 0, MakeGitError(ecode) |
| 128 | } |
| 129 | |
| 130 | return len(p), nil |
| 131 | } |
| 132 | |
| 133 | func (stream *BlobWriteStream) Free() { |
| 134 | runtime.SetFinalizer(stream, nil) |
nothing calls this directly
no test coverage detected