Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 21 Feb 2004 21:35:04 +0200
From:      Petri Helenius <pete@he.iki.fi>
To:        Maxime Henrion <mux@freebsd.org>
Cc:        FreeBSD - net <freebsd-net@freebsd.org>
Subject:   Re: malloc (0)
Message-ID:  <4037B2E8.8070407@he.iki.fi>
In-Reply-To: <20040221170635.GL35475@elvis.mu.org>
References:  <40378E93.3010804@rommon.com> <20040221170635.GL35475@elvis.mu.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Maxime Henrion wrote:

>In C99, malloc(0) is legal.  From n869.txt :
>
>%%
>If the size of the space requested is zero, the behavior is
>implementation-defined: either a  null pointer  is returned,
>or the behavior is as if the size were some nonzero value,
>except that the returned  pointer  shall not  be  used  to
>access an object.
>%%
>
>As a side note, free(NULL) is also legal in C99.
>
>  
>
I´m actually aware how the standard approaches the issue, but my 
question was more directed to how FreeBSD "code style" approaches the 
issue.
Personally I feel that debugging would be easier if mallocing 0 bytes 
and free and realloc of NULL pointers would not spread.

Pete



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