Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!samsung!brutus.cs.uiuc.edu!apple!oracle!news From: gstein@oracle.uucp (Gregory Stein) Newsgroups: comp.sys.mac.programmer Subject: StripAddress... Message-ID: <1990Feb2.010425.28126@oracle.com> Date: 2 Feb 90 01:04:25 GMT Sender: news@oracle.com Reply-To: gstein@oracle.uucp (Gregory Stein) Organization: Oracle Corporation, Belmont, CA Lines: 61 [ I posted this once before and received no response, so I'm trying again... ] Geez, it seems like StripAddress needs to be called *everywhere* if you want to be 32-bit clean. If you maintain any kind of information within a handle, it appears that you are required to call StripAddress to access that information. Now, sure, I can dereference, strip it, and store it so that I don't have to call StripAddress again (say, in a sequence of stores), but as soon as I call a routine that moves memory, I'll have to do it again. I've been programming the Mac for almost six years now, but this whole issue has me kind of stymied. Am I missing something here? For a concrete example, let's define a structure like this: struct foo { int a, b, c; } **bar; bar = (struct foo **) NewHandle(sizeof(struct foo)); Now, when I say "(*bar)->a" is this 32-bit clean? For this example and the current system software it is because the flag bits in the handle represented by bar are zero, so there is no problem (the object is not locked, purgable, or a resource). What happens if I do something like: HLock((Handle)bar); (*bar)->a = f(); /* f() and g() move memory */ (*bar)->b = g(); HUnlock((Handle)bar); Now, is this fragment still 32-bit clean? I would assume it isn't because when the dereference (*bar) occurs, I pick up the flag bit in the master pointer. The solution would be to add a StripAddress, but what would happen if I did something like: (*bar)->a = 50; f(); (*bar)->b = 60; g(); (*bar)->c = 70; Do I have to add a strip address everywhere? Well, maybe. I might have this code fragment in a routine that takes bar as a parameter. The calling function may pass a normal handle or a resource handle. Well, what should I do? Calling StripAddress everywhere seems like a job for Mr. Anal Retentive Programmer. Should I ignore the issue when dealing with handles? i.e. if I get a handle with flag bits in the master pointer, then I'm in 24-bit mode and I don't care, but if it has no flag bits then I'm in 32-bit mode and I still don't care? This seems to be appropriate, but it also seems like the Mac can run in 32-bit mode but still use the current Memory Manager. Or is 32-bit mode only supposed to be turned on by, say, a NuBus driver who uses lots of StripAddress calls and then turns 32-bit mode off? Thanx for any input. -- Greg Stein -- This posting bears no relation to my employer Arpa: gstein%oracle.uucp@apple.com UUCP: ..!{uunet,apple}!oracle!gstein