Jeffrey_J_Vanepps@cup.portal.com (07/24/88)
[]
K&R says that you can't reliably compare pointers to one another unless
they both point into the same array. But later they do just that in a
storage allocator. Is this a real discrepancy or am I hallucinating?
I found this because I had to replace the malloc/free functions of
Microsoft C 5.0. Free() does not join adjacent free blocks to form
larger free blocks, and we were suffering fragmentation. Implementing
K&R's malloc/free required casting pointers to (unsigned long) so
they could be compared (it saw some of the pointers as negative when
addresses got up into the 7Fxx:xxxx range).
^^^^^^^^^
that's right, ugly segmented address space.
Anyway, I just wondered about the apparent self-contradiction, and if
there was a better way to do this.
Jeff Van Epps
Jeffrey_J_Vanepps@cup.portal.com
P.S. My sympathy to anyone who is forced to work with either DOS or
segmented architectures.henry@utzoo.uucp (Henry Spencer) (07/26/88)
In article <7613@cup.portal.com> Jeffrey_J_Vanepps@cup.portal.com writes: >K&R says that you can't reliably compare pointers to one another unless >they both point into the same array. But later they do just that in a >storage allocator. Is this a real discrepancy or am I hallucinating? For "reliably", read "portably". Storage allocators are non-portable by definition, as you have discovered. -- MSDOS is not dead, it just | Henry Spencer at U of Toronto Zoology smells that way. | uunet!mnetor!utzoo!henry henry@zoo.toronto.edu