Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Dec 2000 07:47:37 +0100
From:      Poul-Henning Kamp <phk@critter.freebsd.dk>
To:        Warner Losh <imp@village.org>
Cc:        "Jacques A. Vidrine" <n@nectar.com>, hackers@FreeBSD.ORG
Subject:   Re: Why not another style thread? (was Re: cvs commit: src/lib/libc/gen getgrent.c) 
Message-ID:  <26015.977122057@critter>
In-Reply-To: Your message of "Sun, 17 Dec 2000 21:59:30 MST." <200012180459.VAA87790@harmony.village.org> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <200012180459.VAA87790@harmony.village.org>, Warner Losh writes:

>Number 2.  ANSI-C (aka c89) requires that free(NULL) work.  We
>shouldn't go out of our way to pander to those machines where it
>doesn't.

The reason why this is so is that it is legal for 
	realloc(ptr, 0):
to return either a NULL pointer or a real pointer, and to remain
consistent, the following sequence should always be legal:

	ptr = malloc(foo);
	ptr = realloc(foo, bar);
	free(ptr);

--
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?26015.977122057>