Fixed memory leak
This commit is contained in:
parent
27385ccab4
commit
3f7c5f369b
@ -43,9 +43,11 @@ public:
|
|||||||
if(isQueueEmpty(_head->_next))return NULL;
|
if(isQueueEmpty(_head->_next))return NULL;
|
||||||
|
|
||||||
T *refToReturn = _head->_next->_value;
|
T *refToReturn = _head->_next->_value;
|
||||||
|
Queue *toDelete(_head->_next);
|
||||||
_head->_next = _head->_next->_next;
|
_head->_next = _head->_next->_next;
|
||||||
|
|
||||||
|
delete toDelete;
|
||||||
|
|
||||||
return refToReturn;
|
return refToReturn;
|
||||||
}
|
}
|
||||||
T remove()
|
T remove()
|
||||||
@ -74,6 +76,7 @@ public:
|
|||||||
toDelete = cursor;
|
toDelete = cursor;
|
||||||
cursor = cursor->_next;
|
cursor = cursor->_next;
|
||||||
|
|
||||||
|
delete toDelete->_value;
|
||||||
delete toDelete;
|
delete toDelete;
|
||||||
}
|
}
|
||||||
_head = this;
|
_head = this;
|
||||||
|
Loading…
Reference in New Issue
Block a user