Boost logo

Boost Users :

From: Mark Storer (MStorer_at_[hidden])
Date: 2003-08-07 15:57:20


*string allocates it's own copy of the string, so your pmem pointer is
leaked.

STL's string templates manage their own memory, you never need to use new or
delete to [de]allocate for them.

--Mark Storer
  Software Engineer
  Cardiff Software
#include <disclaimer>
typdef std::disclaimer<Cardiff> Discard;

> -----Original Message-----
> From: Aaron Campbell [mailto:yg-boost-users_at_[hidden]]
> Sent: Thursday, August 07, 2003 1:22 PM
> To: boost-users_at_[hidden]
> Subject: [Boost-Users] shared_ptr memory leak (newb)
>
>
> why does this leak memory from the first call to "new"?
> how can I prevent the leak?
>
> wchar_t* pmem = new wchar_t[10];
> boost::shared_ptr<std::wstring> cp ( new std::wstring(pmem) );
>
> thanks for the help,
> .Aaron
>
>
>
>
>
> ------------------------ Yahoo! Groups Sponsor
> ---------------------~-->
> Buy Ink Cartridges or Refill Kits for Your HP, Epson, Canon or Lexmark
> Printer at Myinks.com. Free s/h on orders $50 or more to the
> US & Canada. http://www.c1tracking.com/l.asp?cid=5511
> http://us.click.yahoo.com/l.m7sD/LIdGAA/qnsNAA/EbFolB/TM
> --------------------------------------------------------------
> -------~->
>
> Info: <http://www.boost.org>
> Wiki: <http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl>
> Unsubscribe: <mailto:boost-users-unsubscribe_at_[hidden]>
>
>
> Your use of Yahoo! Groups is subject to
http://docs.yahoo.com/info/terms/


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net