This article is from the Mac Programming FAQ, by Jon Watte email@example.com with numerous contributions by others.
The contents of a Handle may move, and when it does, the pointer your
handle is pointing to is changed to point to the new address so your
handle is always valid. The toolbox may call the memory manager to
allocate more memory pretty much anytime you call it (the toolbox) and
when memory is allocated, your handle may move in memory. Don't
dereference a handle into a pointer (or take the address of a field in a
record a handle is double-pointing to) and then call the toolbox and
expect the pointer to still be valid. The only way to ensure that the
pointer will still be valid is to call HLock on the handle to lock it.
Use HGetState and HSetState to save & restore the "locked" state of a
handle when you lock it.