#swapping handles
Jim–
I think the other replies to you message may be confused at least in talking
about virtual method tables and classes. Jud is probably right that you'll
have to copy the object contents.
At first glance, what you're proposing ought to work: simply swapping the
master pointers which are pointed to by the two handles. Unfortunately, I
don't think it can be done quite this simply because the block header (located
before the object's data block itself and maintained by the Memory Manager)
contains a copy of the handle (actually a "relative handle"). If you just
changed the master pointer as you propose, the handle in the block header would
be wrong.
I'm not sure how this copy of the handle in the block header is used–it is
certainly used by the RecoverHandle function, which converts a block pointer
back to a handle, but there are probably other reasons that this handle is
maintained.
Of course, you could update the handle in the block header also, but then you'd
be dependent on the structure of the block header (which may have changed with
System 7 and 32-bit mode).
Look at the Memory Manager chapter in Inside Mac Vol. I for details about the
block header. I think Vol. VI has more info about how these data structures
were changed for System 7; it probably contains strong words to the effect of,
"any programmer trying to manipulate Memory Manager internal structures will be
sent straight to MacHell."
Hope this helps.
–Ken