remove inside a remove after a remove... yeah.... No.

This commit is contained in:
Azaezel 2018-03-13 02:12:59 -05:00
parent 95f7205f61
commit 4a5c36352c

View file

@ -113,14 +113,14 @@ inline void SparseArray<T>::insert(T* pObject, U32 key)
template <class T> template <class T>
inline T* SparseArray<T>::remove(U32 key) inline T* SparseArray<T>::remove(U32 key)
{ {
U32 remove = key % mModulus; U32 sentryID = key % mModulus;
Node* probe = &mSentryTables[remove]; Node* probe = &mSentryTables[sentryID];
while (probe->next != NULL) { while (probe->next != NULL) {
if (probe->next->key == key) { if (probe->next->key == key) {
Node* remove = probe->next; Node* nextProbe = probe->next;
T* pReturn = remove->pObject; T* pReturn = nextProbe->pObject;
probe->next = remove->next; probe->next = nextProbe->next;
delete remove; delete nextProbe;
return pReturn; return pReturn;
} }
probe = probe->next; probe = probe->next;