This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: malloc attributes and realloc
- From: Jeff Sturm <jsturm at one-point dot com>
- To: Ian Lance Taylor <ian at wasabisystems dot com>
- Cc: "Joseph S. Myers" <jsm at polyomino dot org dot uk>, <gcc at gcc dot gnu dot org>
- Date: Thu, 1 Jan 2004 12:32:55 -0500 (EST)
- Subject: Re: malloc attributes and realloc
On 1 Jan 2004, Ian Lance Taylor wrote:
> > What *is* significant is
> > that malloc returns memory initialized with zeros, so that it cannot
> > alias anything.
>
> That's not true, though. malloc() returns an uninitialized block of
> memory.
Doh. Never mind... clearly I've been out of C-land too long.
> If realloc() returns non-NULL, then the return value can not alias any
> valid pointer, because it is no longer valid to use the pointer which
> was passed to it (if realloc() returns NULL, on the other hand, then
> it is still valid to use the pointer which was passed to it). So I
> think it is OK to give realloc() __attribute__((malloc)).
I see. Tricky. Anyway, this makes more sense to me than the existing
comment in libiberty.h.
Jeff