svn commit: r352451 - head/stand/libsa

Warner Losh imp at bsdimp.com
Wed Sep 18 11:59:04 UTC 2019


On Wed, Sep 18, 2019, 9:44 AM Hans Petter Selasky <hps at selasky.org> wrote:

> On 2019-09-18 10:37, Warner Losh wrote:
> > On Wed, Sep 18, 2019, 12:18 AM Conrad Meyer <cem at freebsd.org> wrote:
> >
> >> Well, hang on; it's also perfectly legal for a malloc implementation
> >> to return NULL for requests of zero bytes.  You can access exactly the
> >> number of bytes requested in the allocation; and free(NULL) works as
> >> expected.  NULL (0) is also aligned to any size you could want.
> >>
> >
> > Legal, yes.  But it is different than all the other FreeBSD environments,
> > so the loader becomes the odd man out. This restores the consistency.
> >
>
> Hi,
>
> The problem is the code that use malloc() that take NULL as a failure,
> even if the size is zero :-)
>
> array = malloc(n * sizeof(q));
> if (array == NULL)
>       goto failure;
>

Such code isn't portable...

Warner

--HPS
>
>


More information about the svn-src-head mailing list