alternative setting.
When looking up matching EndpointInfo and InterfaceSetting for
an endpoint, a reference to range variable is stored. If range is
allowed to continue, the value of this variable will be updated.
It's a trick to allow use of "nil" pointer as a "found" variable, but it
requires a careful management of the range iterations.
Previously number of iso packets could have amounted to a transfer
buffer larger than passed buffer, which could lead to overflow.
Now the number of bytes requested from device is always smaller or equal
to the buffer size.
In theory, it could lead to inefficiencies in transfer: if max packet
size is 1024 and user request 2046 bytes of data, transfer will return at most
1024 bytes, while it could use a more efficient 2 packets of 1023 bytes.
But at least it's correct now. It seems that for efficiency the user would
always use the reported max packet size anyway.
The device could still send more data than requested, but libusb takes
care of it.
Go1.7:
runtime: bad pointer in frame
github.com/kylelemons/gousb/usb.(*fakeLibusb).open at 0xc420045ce0: 0x1
fatal error: invalid stack pointer
Use an arbitrary C-allocated pointer instead.
libusb_device, since the struct is not defined in libusb headers (only
name is declared), as such the compiler doesn't know the size of the
struct to allocate.