mirror of
https://github.com/siemens-mobile-hacks/node-serialport-bindings-cpp.git
synced 2026-11-25 18:37:19 +00:00
code clenaup and release created objects
This commit is contained in:
parent
c2e0092875
commit
d653ac396c
1 changed files with 10 additions and 3 deletions
|
|
@ -459,16 +459,23 @@ static io_service_t GetUsbDevice(io_service_t service)
|
|||
if (status == kIOReturnSuccess)
|
||||
{
|
||||
io_service_t currentService;
|
||||
while ((currentService = IOIteratorNext(iterator)))
|
||||
while ((currentService = IOIteratorNext(iterator)) && device == 0)
|
||||
{
|
||||
io_name_t serviceName;
|
||||
status = IORegistryEntryGetNameInPlane(currentService, kIOServicePlane, serviceName);
|
||||
if (status == kIOReturnSuccess && (IOObjectConformsTo(currentService, kIOUSBDeviceClassName))) {
|
||||
if (status == kIOReturnSuccess && IOObjectConformsTo(currentService, kIOUSBDeviceClassName)) {
|
||||
device = currentService;
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// Release the service object which is no longer needed
|
||||
(void) IOObjectRelease(currentService);
|
||||
}
|
||||
}
|
||||
|
||||
// Release the iterator
|
||||
(void) IOObjectRelease(iterator);
|
||||
}
|
||||
|
||||
return device;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue