Add check for NULL list head in makeEmpty
This commit is contained in:
parent
ac46149191
commit
58d77e09cd
Binary file not shown.
|
@ -130,8 +130,10 @@ bool SingleList::replace(int val, int key)
|
|||
*/
|
||||
void SingleList::makeEmpty()
|
||||
{
|
||||
Node *nextNode = head->next;
|
||||
Node *temp;
|
||||
Node *nextNode, *temp;
|
||||
|
||||
if (head == NULL) return;
|
||||
nextNode = head->next;
|
||||
delete head;
|
||||
head = NULL;
|
||||
while(nextNode != NULL) {
|
||||
|
|
Loading…
Reference in New Issue