/* * This method should be used with care. In particular, it is wrong to detach from a freelist * while iterating over it unless the detach stops further iteration. */ void detachInternal(MM_HeapRegionDescriptorSegregated *cur) { _length--; MM_HeapRegionDescriptorSegregated *prev = cur->getPrev(); MM_HeapRegionDescriptorSegregated *next = cur->getNext(); if (prev != NULL) { Assert_MM_true(prev->getNext() == cur); prev->setNext(next); } else { Assert_MM_true(cur == _head); } if (next != NULL) { Assert_MM_true(next->getPrev() == cur); next->setPrev(prev); } else { Assert_MM_true(cur == _tail); } cur->setPrev(NULL); cur->setNext(NULL); if (_head == cur) { _head = next; } if (_tail == cur) { _tail = prev; } }
MM_HeapRegionDescriptorSegregated *dequeueInternal() { MM_HeapRegionDescriptorSegregated *result = _head; if (_head != NULL) { _length--; _head = result->getNext(); result->setNext(NULL); if (NULL == _head) { _tail = NULL; } else { _head->setPrev(NULL); } } return result; }