Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: proper disposal of HID queues and interfaces?



Title: Re: proper disposal of HID queues and interfaces?
I don’t know anything about HID in particular, but I vaguely remember there is a bug in the USB user client such that Release implies unconditional Close. This is probably why my IOKitLib class library contains this line of code:

/* ULONG releaseResult = */ (**fWrapped).Release (fWrapped);

It would be nice if this comment were more explicit, but the fact that I did this with a comment at all tells me I thought this was truly weird. If I had simply cast it to void, it would have meant “I’m throwing away this return value because it’s irrelevant,” but the comment tells me I thought it was highly relevant and wanted to make proper use of it but could not. The comment is the code I wish I could have written. :-)

Another way to address this would be to avoid closing the interface if you know you’re going to release it immediately thereafter, but I probably opted not to do this because I was writing a class library at the time and didn’t want to make that kind of assumption in the general case.

I would be interested to know if this bug still lurks in the USB user client — it’s the sort of thing I would have reported in Radar — but I am too busy at the moment to go spelunking the current Darwin sources.


— Pete Gontier <http://www.m-audio.com/>



From: Andrew Garber <email@hidden>
Reply-To: Andrew Garber <email@hidden>
Date: Mon, 25 Jul 2005 00:50:12 -0700
To: <email@hidden>
Subject: proper disposal of HID queues and interfaces?

Hey all! Just wondering if there is anything redundant about the way I
dispose of HID queues and interfaces. Here's what I'm doing:

// The queue is running (it has been started), and the
// interface is closed at this point

// Elsewhere in the program, I have the following set of declarations:
// IOHIDDeviceInterface **interface;
// IOHIDQueueInterface **queue;
// CFRunLoopSourceRef runLoopSource;

(*interface)->open(interface, 0);
(*queue)->stop(queue);
CFRunLoopRemoveSource(myRunLoop,
                      runLoopSource,
                      kCFRunLoopDefaultMode);
(*queue)->dispose(queue);
(*interface)->close(interface);
(*interface)->Release(interface);

So am I doing any redundant calls?
Could I instead just call the interface's Release method, or would
that lead to memory leaks / other problems?
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Usb mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/usb/email@hidden

This email sent to email@hidden

References: 
 >proper disposal of HID queues and interfaces? (From: Andrew Garber <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.