This is the mail archive of the gcc-patches@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]

Re: Patch: malloc function attribute


 > 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


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