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: Handles and Pointers [was: performance issues]




On Mar 30, 2005, at 11:56 AM, Mike Lazear wrote:

Okay, If HLock and HUnlock are just no-ops I'm just going to remove them.  I have a wrapper around NewPtr and DisposePtr so that should be easy to change to malloc() and free().  I could easily remove my wrapper for NewPtr and just call malloc throughout my code but free is another story.  My DisposePtr wrapper always makes sure that the pointer just freed is set to NULL.



Be aware that there is an important side effect of HLock/HUnlock, etc: they set the "MemErr" global to noErr on success.  You could have subtle bugs if you were inadvertently relying on that behavior.

Also, I saw another comment about using GetPtrSize - if at all possible, you should maintain the size of your allocation if you'll think you'll need it later.  GetPtrSize is rather inefficient.

--smz

 _______________________________________________
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>)
 >Re: Handles and Pointers [was: performance issues] (From: Mike Lazear <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.