Update for new libusb_get_pollfds API

This commit is contained in:
Daniel Drake 2008-03-13 12:54:27 +00:00
parent f546fa2555
commit 156e5e7d7c

View file

@ -291,21 +291,26 @@ API_EXPORTED int fp_get_next_timeout(struct timeval *tv)
*/ */
API_EXPORTED size_t fp_get_pollfds(struct fp_pollfd **pollfds) API_EXPORTED size_t fp_get_pollfds(struct fp_pollfd **pollfds)
{ {
struct libusb_pollfd *usbfds; struct libusb_pollfd **usbfds;
struct libusb_pollfd *usbfd;
struct fp_pollfd *ret; struct fp_pollfd *ret;
size_t cnt; size_t cnt = 0;
size_t i; size_t i = 0;
cnt = libusb_get_pollfds(&usbfds); usbfds = libusb_get_pollfds();
if (cnt <= 0) { if (!usbfds) {
*pollfds = NULL; *pollfds = NULL;
return cnt; return -EIO;
} }
ret = g_malloc(sizeof(struct libusb_pollfd) * cnt); while ((usbfd = usbfds[i++]) != NULL)
for (i = 0; i < cnt; i++) { cnt++;
ret[i].fd = usbfds[i].fd;
ret[i].events = usbfds[i].events; ret = g_malloc(sizeof(struct fp_pollfd) * cnt);
i = 0;
while ((usbfd = usbfds[i++]) != NULL) {
ret[i].fd = usbfd->fd;
ret[i].events = usbfd->events;
} }
*pollfds = ret; *pollfds = ret;