🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5220

Pointer comparison question

#5220
From: Jeffrey_J_Vanepps
Date: Sat, 23 Jul 1988 23:14
23 lines
1430 bytes
[]

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.
Technical Details
Message-ID: <7613@cup.portal.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!decvax!decwrl!sun!pitstop!sundc!seismo!uunet!portal!cup.portal.com!Jeffrey_J_Vanepps
References: <1608@dataio.Data-IO.COM> <469@m3.mfci.UUCP> <513@proxftl.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!water!watmath!clyde!bellcore!decvax!decwrl!sun!pitstop!sundc!seismo!uunet!portal!cup.portal.com!Jeffrey_J_Vanepps
From: Jeffrey_J_Vanepps@cup.portal.com
Newsgroups: comp.std.c
Subject: Pointer comparison question
Message-ID: <7613@cup.portal.com>
Date: 23 Jul 88 23:14:05 GMT
References: <1608@dataio.Data-IO.COM> <469@m3.mfci.UUCP> <513@proxftl.UUCP>
Distribution: na
Organization: The Portal System (TM)
Lines: 23
XPortal-User-Id: 1.1001.4153