Jump to content

  • Log In with Google      Sign In   
  • Create Account


#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