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: [RFC] Fixes to bootstrap from a C++ compiler (part 1)


On Jun 25, 2004, "Gabriel Dos Reis" <gdr@acm.org> wrote:

> 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.

Having a single ALLOC macro, instead of ALLOC_1 and ALLOC_N that Mark
proposed, isn't as C++-friendly, since new and new[] are different
operators, and you can't hand the return value of the latter to
delete, only to delete[].  So, if we're planning on eventually
switching to C++, we'd better differentiate between allocating objects
and allocating arrays.

-- 
Alexandre Oliva             http://www.ic.unicamp.br/~oliva/
Red Hat Compiler Engineer   aoliva@{redhat.com, gcc.gnu.org}
Free Software Evangelist  oliva@{lsd.ic.unicamp.br, gnu.org}


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