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


Gabriel Dos Reis <gdr@integrable-solutions.net> writes:

> | This isn't directly relevant to the current thread, but another aspect of
> | malloc-like functions came up recently: the memory they return is writable.
> | I.e., if char *p was returned by an attribute(malloc) function, then
> |   if (*p != 'a')
> |     *p = 'a';
> | 
> | can be safely optimized into
> |   *p = 'a';
>
> That transformation caanot be applied for pointers returned by
> realloc, in general.

Huh? Are you asserting that realloc may return a pointer to read-only
memory?

zw


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