This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: Patch: malloc function attribute
- To: "Kaveh R. Ghazi" <ghazi at caip dot rutgers dot edu>
- Subject: Re: Patch: malloc function attribute
- From: Jeffrey A Law <law at cygnus dot com>
- Date: Mon, 29 Nov 1999 02:01:27 -0700
- cc: green at cygnus dot com, gcc-patches at gcc dot gnu dot org
- Reply-To: law at cygnus dot com
In message <199911290635.BAA01815@caip.rutgers.edu>you write:
> > From: Anthony Green <green@cygnus.com>
> >
> > Jeff wrote:
> > > Otherwise it looks great. Please install it.
> >
> > Done (with your suggestions). Thanks,
> > AG
>
> Hey great! I suggested this in September hoping someone would
> consider it to be worthwhile, but the discussion trailed off when no
> one could decide if __restrict__ would already satisfy the
> functionality. (Any idea about that?)
I don't remember getting a conclusive answer on that issue. Also note
that attributes are probably more likely to work in a language like Java
than __restrict. ie, __attribute__ is *supposed* to be a fairly language
independent way to tag items. __restrict on the other hand is fairly
C/C++ centric.
> QUESTION: should realloc and similar functions which could possibly
> return the same pointer more than once have this attribute? I don't
> think so, so I didn't mark xrealloc or spaces.
I believe xrealloc is safe. Consider the conditions under which is
can return the same pointer, I believe all are safe.
> list. (BTW, what the heck is spaces good for anyway?)
No idea. Who added it?
> gcc:
> * calls.c (special_function_p): Add `strdup' to the list of
> functions which have attribute malloc by default.
>
> include:
> * ansidecl.h (ATTRIBUTE_MALLOC): New macro.
>
> * libiberty.h (buildargv, dupargv, concat, choose_temp_base,
> make_temp_file, xmalloc, xcalloc, xstrdup, xmemdup): Add
> ATTRIBUTE_MALLOC.
> (xatexit): Remove __GNUC__ check, add ATTRIBUTE_NORETURN.
The only concern I have is people bootstrapping with older snapshots may
get errors because there was no malloc attribute supported in older snapshots.
How do you propose to handle that?
jeff