Path: utzoo!attcan!uunet!world!decwrl!fernwood!portal!sv!daven From: daven@svc.portal.com Newsgroups: comp.sys.mac.programmer Subject: Re: Swapping Handles Message-ID: <1990Dec10.063349.21371@svc.portal.com> Date: 10 Dec 90 06:33:49 GMT References: <2599@runxtsa.runx.oz.au> Organization: Software Ventures Lines: 38 In article <2599@runxtsa.runx.oz.au> karlg@runxtsa.runx.oz.au (Karl Goiser) writes: >Quick question for you Gurus: > >If I swap the master pointers (?) of two Handles like so: > >VAR > H1, H2: Handle; > >... > >Ptemp:= H2^; >H2^:= H1^; >H1^:= H2^; >... > >will I hurt anybody or anything (including myself)? No! Don't even think of doing this! The reason why is that the Memory manager will likely become terribly confused if you do this. When the Mem Mgr creates a relocatable block, it places an 8 byte header in front of the block it gives you. This header contains a pointer back to the Master pointer. (Well, actually it's an offset to the Master pointer relative to the beginning of the heap zone) Changing the Master pointer would result in a situation where the Master pointer and the block's Relative pointer are no longer in agreement. A final point. Unless you know exactly who all has made copies of your handles, including whether the MacOS has or not, you risk having a copy made before you exchange the Master pointers, and then that copy will now point to the wrong relocatable block. -- ------------------------------------------------------------------------------- Dave Newman - Sofware Ventures | daven@svc.portal.com | AppleLink: D0025 Berkeley, CA (415) 644-3232 | AOL: MicroPhone | CIS: 76004,2161 -------------------------------------------------------------------------------