Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualEndurion

Posted 02 December 2012 - 02:14 PM

I don't want to sound harsh, but seriously, use std::list. Your code is leaking all over.
No, your compiler is surely not buggy. You don't call destructors directly.

Have you used the debugger and checked where it crashes?


The crash comes probably from that loop. Think about it, you're reaching the last element, so sentinel = sentinel->next; is setting sentinel to NULL.
And then you try to access sentinel->prev. Null pointer access!

sentinel = list;
   cout << sentinel->data->x << "*" << endl;
   while (sentinel != NULL)
   {
	    sentinel = sentinel->next;
	    delete sentinel->prev;
   }

#2Endurion

Posted 02 December 2012 - 01:50 PM

I don't want to sound harsh, but seriously, use std::list. Your code is leaking all over.
No, your compiler is surely not buggy. You don't call destructors directly.

Have you used the debugger and checked where it crashes?


The crash comes probably from that loop. Think about it, you're reaching the last element, so sentinel = sentinel->next; is setting sentinel to NULL.
And then you try to access sentinel->prev. Null pointer access!

sentinel = list;
   cout << sentinel->data->x << "*" << endl;
   while (sentinel != NULL)
   {
	    sentinel = sentinel->next;
	    delete sentinel->prev;
   }

#1Endurion

Posted 02 December 2012 - 01:50 PM

I don't want to sound harsh, but seriously, use std::list. Your code is leaking all over.

Use the debugger and see where it actually crashes.

No, your compiler is surely not buggy. You don't call destructors directly.


The crash comes probably from that loop. Think about it, you're reaching the last element, so sentinel = sentinel->next; is setting sentinel to NULL.
And then you try to access sentinel->prev. Null pointer access!

sentinel = list;
   cout << sentinel->data->x << "*" << endl;
   while (sentinel != NULL)
   {
	    sentinel = sentinel->next;
	    delete sentinel->prev;
   }

PARTNERS