This is the mail archive of the
mailing list for the Cygwin project.
RE: new vs malloc, was BUG - Cygwin to GNU CC compatibility
- From: Ross Smith <rosss at pharos dot co dot nz>
- To: 'Samuel' <samuel at socal dot rr dot com>, cygwin at cygwin dot com
- Date: Wed, 7 Aug 2002 13:28:40 +1200
- Subject: RE: new vs malloc, was BUG - Cygwin to GNU CC compatibility
> From: Samuel [mailto:firstname.lastname@example.org]
> From: "Ross Smith" <email@example.com>
> > No user code should ever use "delete"; it should only appear in the
> > implementation of a container or smart pointer.
> What? I must misunderstand what is meant, since user code
> must always use
> "delete" for each "new", unless the documentation of a
> function clearly
> states that it is the function's responsibility to "delete".
This is what smart pointers (std::auto_ptr, boost::shared_ptr, etc) are
for. Anything allocated by new should always be held by a smart pointer
that will handle deletion automatically, never a raw pointer.
Ross Smith ...................... Pharos Systems, Auckland, New Zealand
"C++ is to programming as sex is to reproduction. Better ways might
technically exist but they're not nearly as much fun." - Nikolai Irgens
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html