diff options
author | Daniel Drake <dsd@gentoo.org> | 2008-05-05 17:54:33 +0100 |
---|---|---|
committer | Daniel Drake <dsd@gentoo.org> | 2008-05-05 17:54:33 +0100 |
commit | a95c943ed301dcd20e92b0b3b255568899a4c42e (patch) | |
tree | 442a0fefeacc9d055ac18bede7facb64ec3d0fd8 | |
parent | b27fff633843824744df7d334cb89ece329cafa6 (diff) | |
download | libusb-a95c943ed301dcd20e92b0b3b255568899a4c42e.tar.gz |
free open devices on exit
-rw-r--r-- | libusb/core.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libusb/core.c b/libusb/core.c index 0464bd8..fa70b82 100644 --- a/libusb/core.c +++ b/libusb/core.c @@ -879,15 +879,19 @@ API_EXPORTED int libusb_init(void) */ API_EXPORTED void libusb_exit(void) { - struct libusb_device_handle *devh; usbi_dbg(""); pthread_mutex_lock(&usbi_open_devs_lock); if (!list_empty(&usbi_open_devs)) { - usbi_dbg("naughty app left some devices open!\n"); - list_for_each_entry(devh, &usbi_open_devs, list) + struct libusb_device_handle *devh; + struct libusb_device_handle *tmp; + + usbi_dbg("naughty app left some devices open!"); + list_for_each_entry_safe(devh, tmp, &usbi_open_devs, list) { + list_del(&devh->list); do_close(devh); - /* FIXME where do the open handles get freed? */ + free(devh); + } } pthread_mutex_unlock(&usbi_open_devs_lock); |