Allocate libusb buffers in C (#11)

* add alloc/free_transfer_and_buffer. Manages the buffer memory on the C
side.

* switch libusb.go to use the new alloc/free_transfer_and_buffer. Add
a new buffer() call to get access to the allocated buffer as a Go slice.

* Fake USB transfer uses the new alloc/free/buffer interface.

* Switch to the new libusb.alloc signature, where libusb owns the buffer.

* newUSBTransfer now allocates a separate buffer, do a copy on
endpoint.transfer.

* newUSBTransfer will now allocate it's own buffer.

* Enable autodetach in rawread.
This commit is contained in:
zagrodzki
2017-08-29 12:11:04 +02:00
committed by GitHub
parent bc91dd3f2c
commit 1aaa100bdb
8 changed files with 82 additions and 28 deletions

View File

@@ -17,7 +17,7 @@ package gousb
func (e *endpoint) newStream(size, count int, submit bool) (*stream, error) {
var ts []transferIntf
for i := 0; i < count; i++ {
t, err := newUSBTransfer(e.h, &e.Desc, make([]byte, size), e.Timeout)
t, err := newUSBTransfer(e.h, &e.Desc, size, e.Timeout)
if err != nil {
for _, t := range ts {
t.free()