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 Thursday, 10. May 2007, Jakub Jelinek wrote:
> 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).

Ok, but do you prefer a one-does-everything attribute over orthogonal 
attributes?

In principle I like the idea of tossing alloc_size into malloc attribute, 
except that it doesn't work for realloc. So I'd have to do another attribute 
named realloc to handle that case. So far, so good. 

the next headache would be to check if malloc attribute can really be extended 
by parameters without breaking old compiler support. 

And last but not least, adding alignment would be another attribute parameter 
for malloc attribute. how do you envision that the API should look like? 

for now the first parameter could be alignment, and the 2nd and optional 3rd 
could be alloc_size. but what about future enhancements?

Any feedback appreciated, 
Dirk


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