| |||
| [Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] |
On Mar 30, 2005, at 10:24 AM, Mike Lazear wrote:
P.S. By the way, handles are completely unnecessary in Mac OS X, except for backwards-compatibility with Carbon functions that take them. With Mac OS X's VM system, you can resize a pointer just as easily as you could resize a handle in Mac OS 9.
"Mac OS X implements a highly-tuned, threadsafe allocation library, providing standard implementations of the malloc, calloc, realloc, and free routines, among others. If you are allocating memory using older routines such as NewPtr or NewHandle, you should change your code to use malloc instead. The end result is the same since most legacy routines are now wrappers for malloc anyway."
I thought I had read on this list in the past where someone said handles were no longer necessary but I've never taken them out of my program. Before I go thru and rip out hundreds of calls involving handles I want to make sure that I'm clear (though it sounds pretty darn clear from what Chris already said). Per what Chris says this means there is no reason to ever call HLock or HUnlock, is that correct? Nor do we need to call NewPtr, NewHandle, DisposePtr, DisposeHandle?
Yes and no. HLock and HUnlock are essentially noops (they do set and change the locked bits, but they have no other effect, as the master pointer values never change anyway). There are still plenty of Carbon routines that expect or return handles, and you pretty much have to use valid handles for them, though over time more and more of these are becoming opaque objects (such as the DataHandle in an AEDesc, which stopped being a handle in Panther).
If you're still using handles for your own values that you never pass to Carbon system functions, you can stop now. They don't buy you anything and they cost you extra instructions to dereference.
As for NewPtr and DisposePtr, you should use malloc() and free() instead, and in most cases you can use a properly-cast return value from malloc() anywhere you'd use a Ptr from NewPtr.
_______________________________________________ Do not post admin requests to the list. They will be ignored. Carbon-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/carbon-dev/email@hidden This email sent to email@hidden
| References: | |
| >performance issues (From: "Edwards, Waverly" <email@hidden>) | |
| >Re: performance issues (From: Chris Espinosa <email@hidden>) | |
| >Re: performance issues (From: Mike Lazear <email@hidden>) | |
| >Handles and Pointers [was: performance issues] (From: Chris Espinosa <email@hidden>) |
| Home | Archives | FAQ | Terms/Conditions | Contact | RSS | Lists | About |
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.