suggestion: int fd --> void *handler
nerilex opened this issue · comments
While working on an [adaption for (integration of) USB-devices],(https://github.com/nerilex/libmsr/tree/usb-support) into the library, the direct use of file descriptors turned out problematic.
I temporarily solved it for my for by using a msrio
abstraction layer which manages a table of functions and handlers into which the former filedescriptors are now just indexes.
A generic void*
or some other opaque pointer given to the application would probably ease abstraction and avoid the allocation of tables.
Yeah, the use of file descriptors is a holdover from the original implementation (which I had nothing to do with). I agree that opaque pointers would be a good solution here, although I don't have time in the immediate future to work on changing the codebase to use them.
I'll leave this open as a tracker.
P.S. I'd welcome native USB support, if you're interested in merging it!