Dereference device with a defer call to prevent memory leaks (#98)
We should always dereference devices. c.libusb.open is keeping its own internal reference so there is no risk of breaking anything.
This commit is contained in:
@@ -209,7 +209,7 @@ func (libusbImpl) getDevices(ctx *libusbContext) ([]*libusbDevice, error) {
|
||||
for _, d := range devs {
|
||||
ret = append(ret, (*libusbDevice)(d))
|
||||
}
|
||||
// devices will be dereferenced later, during close.
|
||||
// devices must be dereferenced by the caller to prevent memoryleaks
|
||||
C.libusb_free_device_list(list, 0)
|
||||
return ret, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user