[ODE] RE: ALLOCA
Steve Baker
sjbaker1 at airmail.net
Thu Feb 26 17:56:50 MST 2004
Jon Watte wrote:
> Note that the use of malloc() is still there -- I think there
> are two orthogonal issues (for something as simple as wrapping
> alloca()!)
It really is a bad idea to use malloc/calloc/alloc/free in C++
programs. For one thing, this bypasses any constructors someone
may have written for the object you are making - and for another,
there is danger that you may allocate the space using 'malloc'
and someone else may not realise that an attempt to de-allocate
it with 'delete' (or allocated with 'new' and later 'free'd).
This can result in seriously error-prone code.
If you are writing in C++ you should really try to stick with
new/delete for *all* memory allocations.
> The ## token concatenation has been well supported in ANSI C
> for at least the last 10 years. I use it daily on GCC3 and
> MSVC6.
Yeah - it's pretty standard these days. The only system I've
seen recently that didn't support it was a rather ancient SGI
IRIX-based machine.
---------------------------- Steve Baker -------------------------
HomeEmail: <sjbaker1 at airmail.net> WorkEmail: <sjbaker at link.com>
HomePage : http://www.sjbaker.org
Projects : http://plib.sf.net http://tuxaqfh.sf.net
http://tuxkart.sf.net http://prettypoly.sf.net
-----BEGIN GEEK CODE BLOCK-----
GCS d-- s:+ a+ C++++$ UL+++$ P--- L++++$ E--- W+++ N o+ K? w--- !O M-
V-- PS++ PE- Y-- PGP-- t+ 5 X R+++ tv b++ DI++ D G+ e++ h--(-) r+++ y++++
-----END GEEK CODE BLOCK-----
More information about the ODE
mailing list