Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


KymikoLoco

Member Since 12 Mar 2012
Offline Last Active Feb 11 2013 10:47 AM

#4939127 Cleaning up a vector of pointers?

Posted by KymikoLoco on 10 May 2012 - 02:58 PM

1. Your last post isn't complete. ( I realized a little late you said your dtors were empty, lol )
2. http://www.touch-code-magazine.com/how-to-debug-exc_bad_access/

This might help a little. It seems as though something is accessing some allocated memory after it was released, so your delete/clean up steps are most likely correct, but somewhere down the line something ELSE is trying to access memory you've already freed. Since commenting out the delete *iter stopped the error from happening, the culprit is most likely _mazeMap.

3. Since I am not familiar with xcode or GDB debugger, what is _mazeMap's and iter's REAL definitions? You have
vector _mazeMap;
std::vector::iterator iter = _mazeMap.begin();
which don't seem like correct syntax.
vector< Wall * > _mazeMap;
std::vector< Wall* >::iterator iter = _mazeMap.begin();

It's better to post *exactly* what you have, instead of cleaning it up for a post.

I would also try the _mazeMap.clear(). If you don't, you basically have _mazeMap full of garbage pointers.

4. Get familiar with breakpoints. They will be your best friend in situations like this.


#4936750 How to convert a vector <char> to a const char?

Posted by KymikoLoco on 02 May 2012 - 07:34 AM

It seems as though no one in this thread is on the same page, but yes.
std::vector< std::string > file_name;
file_name.push_back( "C:\Dev\LOADME.obj" );
loadObject( file_name[0] );

// If the above needs a const char * parameter,
// and you don't want to change the definition:
loadObject( file_name[0].c_str() );

I hope this is closer to what you need.


#4935446 MSVC2010 Possible Bug?

Posted by KymikoLoco on 27 April 2012 - 12:21 PM

I don't know if it goes without saying, but did you try a clean/rebuild of your project? It may affect what you see, versus what the debugger thinks is true, if you edit a header and it does not recompile correctly. If it is working, then great, but if you didn't do a rebuild, that may have fixed it. Not saying you forgot, but there was no mention, and can't hurt to cover the bases in case it happens again :)


PARTNERS