ronb@burklabs (Ron Burk ) (10/10/90)
Suppose you have a pointer P1 to chunk of memory of size L1 bytes. Now, given another pointer, P2, I wish to determine whether P2 points within the block of memory defined by P1 and L1. I understand that simple pointer comparison: if(P2 > P1 && P2 < (P1+L1)) { then P1,L1 contains P2 } is not portable. My question is, does anyone know of any environment in which you cannot code a reasonably efficient inline function to perform this test correctly? I conjecture that the worst case in existence is a large-model program under MS-DOS that would require the pointers to be normalized before they are compared. My goal is to be able to write software that requires this operation by assuming that any individual operating system can supply a simple inline function that gets the job done.