Quote:Original post by smart_idiot
std::for_each(m_Sprites.begin(), m_Sprites.end(), destroy_bitmap);
m_Sprites.clear();
Am I right in thinking that the first line deletes the actual bitmaps, then the second line clears the vector?
I've put these two lines in and now when I exit the program it crashes (ie instead of ending cleanly a window appears with an ugly message saying the program "has encountered a problem and needs to close"). Without the above two lines, the program ends cleanly, as expected (though perhaps with some memory wasted as I am not destroying the bitmaps).
It's certainly not the algothingy that's making it crash. I've just tried deleting the bitmaps like this and it still crashes:
for ( int sprite=0 ; sprite < m_Sprites.size() ; sprite++ )
destroy_bitmap( m_Sprites[sprite] );
In case it is relevant, the vector is created like this:
std::vector<BITMAP*> m_Sprites;
This presumably means that the vector holds pointers to BITMAPs rather than BITMAPs. Does this change the way I have to destroy the BITMAPs?
[Edited by - darenking on July 9, 2005 5:01:34 AM]