After running this piece of code I get a message from gdb saying that
curr = curr -> next; causes a seg fault. I don't know why. Any help that could be given would be appreciated.
1 2 3 4 5 6 7 8
void split (list * splitlist , list * & A, list * & B)
{ Link * curr = splitlist -> first;
while ( curr != NULL)
{ A->add(A->first ,curr->data);
curr = curr -> next;
if ( curr != NULL)
B-> add(B->first, curr-> data) ;
curr = curr -> next ; }}
Basically, this is the error thrown by ::operatornew or ::operatornew[] when it can't allocate memory. The three most probable cases for this are either you are allocating more memory than you have, the heap is fragmented enough that you can't allocate enough continuguous memory, or you have done something like trying to allocate an array with a negative size.