Ray Tayek on Tue, 6 Jun 2006 14:02:25 -0500 (CDT)


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [ALACPP] memory leak


At 05:39 PM 1/18/2006, you wrote:
> At 11:21 PM 1/17/2006, you wrote:
> >hi, trying to code up some stuff for a class  ...
>
> it's worse than i thought. the code below seems to also have the leak:
> MapSite *Room::setSide(MapSite::Direction direction,MapSite *mapSite) {
>          MapSite *rc=NULL;
>          pair<map<MapSite::Direction,MapSite *>::iterator,bool>
> p=sides_.insert(map<MapSite::Direction,MapSite
> *>::value_type(direction,mapSite));
>          if(!p.second)
>                  { rc=p.first->second; p.first->second=mapSite; }
> }
>
>
> anybody got a clue


Hi Ray! Some questions:

1. What are you using for a leak detection tool?

i am using this plugin: <http://web-cat.cs.vt.edu/WCWiki/EclipsePlugins/CxxTestPlugin> which includes cxxtest (and a lot more).


2. Can you post the code to the whole class?

attached please find.


3. Why the raw pointers?

haven't studied the latest collection of smart pointers. this is for a c++ class that i will be teaching in a few days at csulb.edu. which flavour of smart pointer do you like?


4. When you put a MapSite into the list, is the map supposed to be the
sole owner of that object now?

the maze owns the mapsites, his dtor cleans up. and the map is <Diection,MapSite *>.

 When the map is destroyed, or when the item
is removed, is it supposed to be destroyed?

no

thanks

---
vice-chair http://ocjug.org/

Attachment: mazecpp.zip
Description: Zip archive

_______________________________________________
alacpp mailing list
alacpp@xxxxxxxxxxx
http://lists.ellipsis.cx/mailman/listinfo/alacpp