darwin: fix resource leak (cached devices are never freed)
authorparafin <parafin@paraf.in>
Mon, 9 Feb 2015 21:28:43 +0000 (00:28 +0300)
committerNathan Hjelm <hjelmn@lanl.gov>
Thu, 12 Feb 2015 18:50:27 +0000 (11:50 -0700)
commitd26cc697ccaba5496b56903eac12dc2b5838af04
tree2b750b8169f31af0010c6a99c8e27fcb80fc7b2e
parentd68750a7ac65e29b41cadacd4231cc68af8a79bd
darwin: fix resource leak (cached devices are never freed)

For each new device (processed by hotplug code) darwin_ref_cached_device
is called twice - in process_new_device and in darwin_get_cached_device
(which is called from the first function). But when the device is detached
only one darwin_deref_cached_device is done - in darwin_destroy_device.
So there is inbalance between ref and deref which causes darwin_cached_devices
list to monotonically grow and consume more and more resources over time.
This commit fixes the problem by adding darwin_deref_cached_device call
to darwin_devices_detached.

Closes #52

Signed-off-by: Nathan Hjelm <hjelmn@mac.com>
libusb/os/darwin_usb.c
libusb/version_nano.h