Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!wuarchive!uunet!hoptoad!wet!wet.UUCP From: naga@wet.UUCP (Peter Davidson) Newsgroups: comp.os.msdos.programmer Subject: Correction to far_ptr_cmp(). Message-ID: <2351@wet.UUCP> Date: 26 Apr 91 13:29:39 GMT Sender: naga@wet.UUCP Distribution: usa Organization: Wetware Diversions, San Francisco Lines: 23 days ago, for comparing far pointers, requires a correction. I forgot to add the (unsigned long) casts in the first two lines. Shoot! We'll at least I noticed before anyone else did (or at least before anyone else posted a correction (or at least before anyone did and it arrived here)). The function returns -1 if the physical memory address of ptr1 is less than that of ptr2, 1 if greater than and 0 if they point to the same memory location. int far_ptr_comp(void far *ptr1,void far *ptr2) { unsigned long p1 = ( ( (unsigned long)FP_SEG(ptr1)<<4 ) + FP_OFF(ptr1) ); unsigned long p2 = ( ( (unsigned long)FP_SEG(ptr2)<<4 ) + FP_OFF(ptr2) ); int result=0; if ( p1 < p2 ) result--; else if ( p1 > p2 ) result++; return ( result ); }