CompuServe Messages

#swapping handles

    16-Jul-93 10:20:20
Sb: #swapping handles
Fm: Jim Dill 72251,1177
To: forum
I would find it handy to be able to take two objects and swap their handles, so that the handle of one pointed to the data of the other and vice versa. Like this: void HSwap(CObject *o1, CObject *o2) { Handle h1 = o1, h2 = o2; Ptr p1 = *h1, p2 = *h2; *h1 = p2; *h2 = p1; } (with appropriate HLocking added). For one thing, this would make for an elegant Do/Undo scheme, in which you could save an object before Doing anything to it, then on Undo or Redo, just swap handles. Is there any danger in this? — Jim