lim@iris.ucdavis.edu (Lloyd Lim) (07/15/90)
A little while ago I posted a question about how to identify real handles. At that time, the method I was using was giving me bus errors from time to time. I got a bunch of responses and I finally settled on using the following routine. Thanks for the help. I was reluctant to use fields belonging to the heap but there didn't seem to be much of a choice. Given a choice between looking at the heap or looking at low memory, I figured the heap fields documented in IM were better. I needed to compare the given address to something to prevent bus errors and TopMem wasn't good enough. As others have mentioned, you could also try using RecoverHandle to really be sure. According to IM, however, HandleZone is supposed to work good enough and I haven't had any problems so far. static Boolean RealHandle(addr) register long addr; { register Boolean real; register THz sysZone, applZone, heapZone; real = FALSE; addr = StripAddress(addr); if (addr && !(addr & 1)) { sysZone = SystemZone(); applZone = ApplicZone(); if (((addr >= (long) &sysZone->heapData && addr < (long) sysZone->bkLim) || (addr >= (long) &applZone->heapData && addr < (long) applZone->bkLim)) && *(long *) addr && !(*(long *) addr & 1)) { heapZone = HandleZone(addr); if (!MemError() && (heapZone == sysZone || heapZone == applZone)) { real = TRUE; } } } return(real); } +++ Lloyd Lim Internet: lim@iris.ucdavis.edu (128.120.57.20) Compuserve: 72647,660 US Mail: 146 Lysle Leach Hall, U.C. Davis, Davis, CA 95616