Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 30 Jun 2006 06:59:37 +0200
From:      Johannes Weiner <hnazfoo@googlemail.com>
To:        freebsd-hackers@freebsd.org
Subject:   Re: Return value of malloc(0)
Message-ID:  <20060630045937.GB97868@leiferikson.flosken.lan>
In-Reply-To: <m33bdnhnv7.fsf@merlin.emma.line.org>
References:  <20060628181045.GA54915@curry.mchp.siemens.de> <20060629054222.GA92895@leiferikson.flosken.lan> <m3bqsceyf2.fsf@merlin.emma.line.org> <20060629162319.GA94921@leiferikson.flosken.lan> <m33bdnhnv7.fsf@merlin.emma.line.org>

next in thread | previous in thread | raw e-mail | index | archive | help
Hi,

On Thu, Jun 29, 2006 at 07:29:16PM +0200, Matthias Andree wrote:
> No, sir. Operator precedence: assign first, and then compare, thus the
> comparison will always be true (else you'd be comparing to undefined
> values, which isn't any better).  You might as well write:
> 
>  foo = malloc(0);
>  /* make noise */

Ok, just for having it done:

	if (foo == (foo = some_val))

.. would be right to check if foo stayed the same. No?

> There is no way to see a 0x800 return from malloc(0) as "error".

So noone should actually use malloc(0) and check the size_t argument before
passing it, I guess.

Hannes
-- 
One must still have chaos in oneself to be able to give
a birth to a dancing star.



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