This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
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