🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #6150

Re: JRComm, VLT, Handshake

#6150
From: Marco Papa
Date: Sun, 28 Oct 1990 23:23
33 lines
1862 bytes
In article <466@faatcrl.UUCP> jprad@faatcrl.UUCP (Jack Radigan) writes:
>andy@cbmvax.commodore.com (Andy Finkel) writes:
>>If your program breaks when location 0 is non NULL this means
>>you have an unitialized pointer somewhere in your program, and
>>are using memory you did not allocate (ie location 0)
>
>  Uh, according to K&R, NULL is a valid assignment for a pointer, so
>how is it unitialized?

Initializing a pointer to NULL is just fine.

>  Where I got bit is in a pathname building routine that I wrote which
>did a strlen() without explicitly checking for NULL first, it now does.

Bad boy :-)

>  But, my question is the NULL pointer itself, if NULL is a valid constant,
>then the location NULL should contain nothing either, right?

WRONG! The following is verbatim from K&R, p. 97, first edition:

"C guarantees that no pointer that validly points at data will contain zero,
so a return value of zero can be used to signal an abnormal event ...".

This means that "dereferencing" a pointer to NULL is INVALID, since such
pointer "does not validly points to data".

>  If I somehow missed something so embarrassingly basic, how come I can't
>find it in K&R, which is supposed to be the last word in 'C'?

Yes, that's pretty basic. You didn't read well enough, I guess :-)

-- Marco
Technical Details
Message-ID: <3043@uscacsc.usc.edu>
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!usc!uscacsc!papa
References: <1990Oct11.235942.2141@caen.engin.umich.edu> <9811@uhccux.uhcc.Hawaii.Edu> <15328@cbmvax.commodore.com> <458@faatcrl.UUCP> <15418@cbmvax.commodore.com> <466@faatcrl.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!uunet!wuarchive!usc!uscacsc!papa
From: papa@uscacsc.usc.edu (Marco Papa)
Newsgroups: comp.sys.amiga.tech
Subject: Re: JRComm, VLT, Handshake
Message-ID: <3043@uscacsc.usc.edu>
Date: 28 Oct 90 23:23:21 GMT
References: <1990Oct11.235942.2141@caen.engin.umich.edu> <9811@uhccux.uhcc.Hawaii.Edu> <15328@cbmvax.commodore.com> <458@faatcrl.UUCP> <15418@cbmvax.commodore.com> <466@faatcrl.UUCP>
Reply-To: papa@uscacsc.UUCP (Marco Papa)
Distribution: na
Organization: Felsina Software, Los Angeles
Lines: 33