[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Does malloc() have to zero the block?
- From: Ralph Hempel <rhempel@...>
- Date: Wed, 19 Sep 2007 15:33:45 -0400
Klaus Ripke wrote:
On Wed, Sep 19, 2007 at 03:02:07PM -0400, Ralph Hempel wrote:
What are Lua's expected semantics of:
what makes you assume that Lua expects anything other than:
1. realloc() an existing block to a size of 0 bytes?
"If size is 0 and ptr is not a null pointer, the object pointed to is freed."
In plain english: the expected semantics is a call to free.
A null pointer save free, kinda.
2. realloc() a new block to a size of 0 bytes?
"If ptr is a null pointer, realloc() behaves like malloc() for the specified size."
read on http://www.opengroup.org/onlinepubs/007908775/xsh/malloc.html :
"If the size of the space requested is 0, the behaviour is implementation-dependent; the value returned will be either a null pointer or a unique pointer."
Just like Roberto said.
What's the issue?
There's no issue. I have a Lua interpreter implemented on a the LEGO
MINDSTORMS NXT, which is a non-POSIX platform and it's crashing
I just want to be sure I'm covering everything.