Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!sun-barr!decwrl!ucbvax!hoptoad!tim From: tim@hoptoad.uucp (Tim Maroney) Newsgroups: comp.sys.mac.programmer Subject: Re: Passing pointers to functions (was Re: HLock) Message-ID: <9389@hoptoad.uucp> Date: 24 Dec 89 01:45:45 GMT References: <859@lclark.UUCP> Reply-To: tim@hoptoad.UUCP (Tim Maroney) Organization: Eclectic Software, San Francisco Lines: 26 In article <859@lclark.UUCP> dan@lclark.UUCP (Dan Revel) writes: >I have been following the HLock thread and would like to get >some clarification. Is it safe to pass pointers to functions >across segment boundaries? (I think this question might be >rephrased: 'are my code segments going to be relocated while >my program is running?', is that right?) > >I have tried doing this running the heapscramble (hs) mode of >Macsbugs with no obvious ill-effects, but still, I wonder... Your code segments may be relocated if you do UnloadSeg on them, as many people recommend. However, MPW at least will generate function pointers into the jump table rather than to the function itself in the case of cross-segment references. Within a single segment, it will produce pointers to the functions. I would hope that THINK C does the same. This means that if you take a function pointer while you're in a different segment from the function, what you actually get is the jump table entry for the functions, so even if the segment is relocated, your pointer will still be valid. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "I've been called an evil genius by cities of assholes... but I know who these people are! And they're on my list!" -- Robert Crumb