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()
|
void SingleList::makeEmpty()
|
||||||
{
|
{
|
||||||
Node *nextNode = head->next;
|
Node *nextNode, *temp;
|
||||||
Node *temp;
|
|
||||||
|
if (head == NULL) return;
|
||||||
|
nextNode = head->next;
|
||||||
delete head;
|
delete head;
|
||||||
head = NULL;
|
head = NULL;
|
||||||
while(nextNode != NULL) {
|
while(nextNode != NULL) {
|
||||||
|
|
Loading…
Reference in New Issue