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]
Other format: [Raw text]

Re: [PATCH] add alloc_size attribute


On Wed, May 09, 2007 at 04:40:03PM +0200, Richard Guenther wrote:
> >> 2007-04-25  Dirk Mueller  <dmueller@suse.de>
> >>         Marcus Meissner <meissner@suse.de>
> >>
> >>         * doc/extend.texi (alloc_size): New attribute.
> >>         * c-common.c (handle_alloc_size_attribute): New.
> >>         * tree-object-size.c (alloc_object_size): Use alloc_size
> >>         attribute, if available.
> >>
> >>         * testsuite/gcc.dg/attr-alloc_size.c: New.
> >
> >Good idea, I just wonder if it wouldn't be better to extend the malloc
> >attribute for this instead (i.e. it could have no arguments as it
> >does now, or one or two as your alloc_size argument does).

BTW, before we have too many different attributes for the allocator
functions, I think besides size we could use also the library implementation
telling the compiler about alignment of the returned pointer (that can be
either constant (e.g. 2*sizeof(void *) for glibc malloc) or one of the
arguments passed to the allocator function (e.g. memalign)).
And also some way how to say where the pointer is returned (most functions
return it as return value, but e.g. posix_memalign sets it by reference
passed to the first argument).

	Jakub


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