Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Sep 2019 10:20:58 -0600
From:      Ian Lepore <ian@freebsd.org>
To:        Toomas Soome <tsoome@FreeBSD.org>, src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r352451 - head/stand/libsa
Message-ID:  <c399d918867b66aaf126c935b07511a66365f9ec.camel@freebsd.org>
In-Reply-To: <201909171616.x8HGGlkb066218@repo.freebsd.org>
References:  <201909171616.x8HGGlkb066218@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, 2019-09-17 at 16:16 +0000, Toomas Soome wrote:
> Author: tsoome
> Date: Tue Sep 17 16:16:46 2019
> New Revision: 352451
> URL: https://svnweb.freebsd.org/changeset/base/352451
> 
> Log:
>   loader: revert r352421
>   
>   As insisted by kib, malloc(0) is quite legal.
> 
> Modified:
>   head/stand/libsa/zalloc_malloc.c
> 
> Modified: head/stand/libsa/zalloc_malloc.c
> ==============================================================================
> --- head/stand/libsa/zalloc_malloc.c	Tue Sep 17 15:53:40 2019	(r352450)
> +++ head/stand/libsa/zalloc_malloc.c	Tue Sep 17 16:16:46 2019	(r352451)
> @@ -73,9 +73,6 @@ Malloc_align(size_t bytes, size_t alignment)
>  {
>  	Guard *res;
>  
> -	if (bytes == 0)
> -		return (NULL);
> -
>  #ifdef USEENDGUARD
>  	bytes += MALLOCALIGN + 1;
>  #else

For the record, you're both right.  In both the C and posix standards
for malloc(), an implementation is allowed to return either NULL or a
unique pointer which cannot be used to access any memory but must be
passed to free().

-- Ian




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