Boost logo

Boost Users :

From: Sebastian Redl (sebastian.redl_at_[hidden])
Date: 2006-01-11 11:54:36

Olga Gerchikov wrote:

>Is there a safe idiom to prevent memory leak? Should i use auto_ptr in
> C++?
> Or should I use the smart pointer library in boost? Which is the
>simplest solution?
Using a smart pointer will prevent the leak. Which smart pointer depends
on your requirements. If you KNOW you only need it in the calling scope,
use boost::scoped_array. Otherwise use boost::shared_array.
std::auto_ptr is not applicable because it can only handle pointers
allocated with new, not those allocated with new[].

Sebastian Redl

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at