Fix autotools run.
Improve readability.
Don't get same data twice!
Remove useless extern keywords from definition.
Add missing definitions.
Rename pointer to more meaningfull names like in the other files.
Sync Transfer class with libusb.h definition (byte instead of int mostly).
Add several yet unimplemented methods.
Update test.
numAltsetting is an int, in both the Java class and libusb.h.
bSynchAddress is a byte in both Java and libusb.h.
Set size to zero on reset. Else getting the size is incorrect, and later when checking in get() it would pass the check and you'd access a NULL ptr.
Fix typo.
Replace mentions of struct libusb_context with the typedef libusb_context, as is expected by the API.
Also fix init/exit to not handle the default context in any special way: the default context is reference counted, and it is thus NOT an error to call init on it multiple times, or exit for that matter afterwards.
Work on array directly to avoid a full copy.
Fix LongBuffer vs IntBuffer usage for getNextTimeout: it has to work with long.
Fix method signatures.
Add TODO wrt wrong usage of completed flag.
We don't need to concern ourselves with length in getStringDescriptorAscii when using a StringBuffer and appending to it.
In C you need to have a length parameter to know how much you can write, here we can always just get the maximum, which is quite small, and then append to the StringBuffer, which will take care of any length management.
Consistently use ByteBuffers in the LibUsb class, getPortPath was the only method that used a byte array, and I personally prefer consistency here, as it gets used like any other function expected to get a char * + length.
I see now why ints were used here, because all the constants are ints and as such you don't have to do annoying casts and conversions.
I agree with this on set*() calls, but I argue that it is more correct to return the appropriate, smaller type on get*() calls, the same as with the other classes: the values you can read are of appropriate, original size.
Fix signature comments.
Don't create new scopes in macros, it only makes sense if you have frequent name collisions, and worsens performance.
Change DIRECT_BUFFER to not call the isDirect() method (expensive!), but instead to check the return value of getDirectBufferAddress, which is always used anyway.
It also detects cases where the JVM doesn't support direct buffers and other error conditions this way.
Fix memory leak: if you malloc, you must also free, JNI never touches manually allocated memory.
Also, I don't see why there is any need to deviate from using a pointer to using a ByteBuffer here, it will not make memory management automatic, and just makes the DeviceDescriptor "different" for no apparent reason. So changed back to pointer.
Fix signature comments.
Fix handleEventsTimeoutCompleted and handleEventsCompleted, they require access to a variable representing an integer, that gets set from somewhere outside, like a transfer callback.
The only way to do this in Java is by direct buffers, which IntBuffers can be if allocated correctly, as explained in the JavaDoc.