🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c
Article #5856

Re: realloc

#5856
From: Oisin
Date: Sun, 02 Apr 1989 20:36
36 lines
2170 bytes
in Article 131 of comp.std.c: gregg@ihlpb.ATT.COM (Wonderly)  says:
>From article <10170@bloom-beacon.MIT.EDU>, by scs@adam.pika.mit.edu (Steve Summit):
[ anecdote deleted ]
>> kept secret that realloc is supposed to behave gracefully at
>> a slightly special-cased boundary point: when handed a NULL
>> pointer and a nonzero size, it acts essentially as a malloc.
>
>I read the man page for realloc and it said nothing about this.  Is it
>not possible for you to type
>
>	if (ptr == NULL)
>		ptr = malloc (nbytes);
>	else
>		ptr = realloc (ptr, nbytes);
>
>or are you one of those people that assumes (*((char *)NULL) == 0) too?
[ more flame deleted ]

Pardon my ignorance, but if I'm wrong you can flame me too...
Does the draft not specify that whatever implementation of NULL is used, 
the compiler must guarantee that a ptr containing that implementation's
version of NULL must test as false?  (Notice I did not say it had to
BE false, just that the compiler must evaluate a logical test on it
as being false).  I'm don't write compilers or anything like that..
I'm just a "dumb end user" of C, but if my understanding is wrong, then
I and a lot of other programmers will have to "mend our ways".  I
stopped wasting my employers time with the redundant "== NULL" when
I read about that guarantee being in the standard.  Please correct
me if I am "bugging" my programs.

........................................................................
Oisin "Curly" Curtin -- uucp:uunet!attcan!cmtl01!oisin
Disclaimer- Opinions are my own.  CNR, AT&T and my wife don't want them.
........................................................................
Money is the root of all evil, and man needs roots
Technical Details
Message-ID: <1196@cmtl01.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!attcan!cmtl01!oisin
References: <10170@bloom-beacon.MIT.EDU> <10032@ihlpb.ATT.COM>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!cmtl01!oisin
From: oisin@cmtl01.UUCP (Oisin)
Newsgroups: comp.std.c,comp.lang.c
Subject: Re: realloc
Summary: if( NULL && !flame )
Keywords: if NULL == 0
Message-ID: <1196@cmtl01.UUCP>
Date: 2 Apr 89 20:36:09 GMT
References: <10170@bloom-beacon.MIT.EDU> <10032@ihlpb.ATT.COM>
Reply-To: oisin@cmtl01.UUCP (Oisin)
Followup-To: comp.std.c,comp.lang.c
Organization: AT&T Canada Inc., Montreal
Lines: 36