This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [RFC] Fixes to bootstrap from a C++ compiler (part 1)
You Wrote Mark Mitchell
>> In C++, you have new and delete, which have "magic" behavior in this
>> area. When you use other memory allocators, the collection of
>> otherwise unnecessary casts gets a bit old.
>
> I suppose we could introduce a macro along the lines of:
>
> #define ALLOC(bytes, type) \
> ((type *) xmalloc (bytes))
Precisely. I would propose the the slight variation:
#define ALLOC(numelt, type) \
((type *) xmalloc (numelt * sizeof (type)))
where NUMELT is the the number of elements of type we want
to place in the storage returned by the allocation function.