This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: malloc function attribute
- To: mark at codesourcery dot com, vonbrand at inf dot utfsm dot cl
- Subject: Re: Patch: malloc function attribute
- From: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Date: Tue, 30 Nov 1999 17:06:28 -0500 (EST)
- Cc: gcc-patches at gcc dot gnu dot org, green at cygnus dot com, law at cygnus dot com, richard dot earnshaw at arm dot com
> From: Mark Mitchell <mark@codesourcery.com>
>
> This discussion has gone somewhat off track. The point is this:
>
> o The standard specifically allows realloc to return the value
> passed in. It doesn't say that you can't use the old variable
> any more in that case. So, I'm quite confident that:
>
> if ((y = realloc (x, 20)) == x)
> y[2] = 6;
>
> is perfectly legal ANSI/ISO C (modulo alignment, sizes of things,
> etc.)
>
> o As an author of portable code you must be conservative, and assume
> that realloc always copies. You have no idea what realloc might
> do on some platform not yet imagined.
>
> o As a author of a compiler, you must be conservative, and assume
> that realloc never copies. You have no idea what the user might
> know about the realloc on their platform.
Yes, very well put. It was my suspicion that this is how we should do
things that lead me to ask the question about realloc in the first
place.
So my intention now is to avoid marking xrealloc and to take out the
mark on realloc. I will check in this change tonight, thanks everyone
for all of your input.
--Kaveh
--
Kaveh R. Ghazi Engagement Manager / Project Services
ghazi@caip.rutgers.edu Qwest Internet Solutions