Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!ames!oliveb!apple!darin From: darin@Apple.COM (Darin Adler) Newsgroups: comp.sys.mac.programmer Subject: Re: Toolbox Gotchas (LONG) Message-ID: <1467@internal.Apple.COM> Date: 20 Apr 89 07:45:07 GMT References: <10050096@accuvax.nwu.edu> Organization: Apple Lines: 28 In article <10050096@accuvax.nwu.edu> jln@accuvax.nwu.edu (John Norstad) writes: > Gotcha #3. Don't believe Inside Macintosh. > > On page IM II-34 we read the following warning in the description of the > HandleZone routine: "If handle h is empty (points to a NIL master pointer), > HandleZone returns a pointer to the current heap zone." This is false - > HandleZone properly returns a pointer to the heap zone that contains the > master pointer. See Gotcha #2 above. This is incorrect. Since the publication of Inside Macintosh Volume II, HandleZone has been *slightly* enhanced (along with the rest of the Memory Manager) to handle the system heap as a special case. The sentence could be correctly reworded: "If handle h is empty (points to a NIL master pointer), HandleZone returns a pointer to the current heap zone, unless the handle points somewhere within the system heap zone and the current heap zone is the application heap zone, in which case it returns a pointer to the system heap zone." This could return suprising results, since you can create a heap zone in the middle of the system heap (in a nonrelocatable or locked relocatable block), and HandleZone will return misleading values. This hack in the ROM (and in system patches) lets you be somewhat haphazard about what the current zone is as long as you stick mostly with the system heap and the application heap. -- Darin Adler, System Software Scapegoat, Apple Computer Internet: darin@Apple.com UUCP: {nsc,sun}!apple!darin