This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]