| 814 | } |
| 815 | |
| 816 | void HandleSystem::UnlinkHandleFromOwner(QHandle *pHandle, unsigned int index) |
| 817 | { |
| 818 | /* Unlink us if necessary */ |
| 819 | unsigned int ident_index; |
| 820 | if (IdentityHandle(pHandle->owner, &ident_index) != HandleError_None) |
| 821 | { |
| 822 | /* Uh-oh! */ |
| 823 | assert(pHandle->owner == 0); |
| 824 | return; |
| 825 | } |
| 826 | |
| 827 | pHandle->owner = NULL; |
| 828 | |
| 829 | /* Note that since 0 is an invalid handle, if any of these links are 0, |
| 830 | * the data can still be set. |
| 831 | */ |
| 832 | QHandle *pIdentity = &m_Handles[ident_index]; |
| 833 | |
| 834 | /* Unlink case: We're the head AND tail node */ |
| 835 | if (index == pIdentity->ch_prev && index == pIdentity->ch_next) |
| 836 | { |
| 837 | pIdentity->ch_prev = 0; |
| 838 | pIdentity->ch_next = 0; |
| 839 | } |
| 840 | /* Unlink case: We're the head node */ |
| 841 | else if (index == pIdentity->ch_prev) { |
| 842 | /* Link us to the next in the chain */ |
| 843 | pIdentity->ch_prev = pHandle->ch_next; |
| 844 | /* Patch up the previous link */ |
| 845 | m_Handles[pHandle->ch_next].ch_prev = 0; |
| 846 | } |
| 847 | /* Unlink case: We're the tail node */ |
| 848 | else if (index == pIdentity->ch_next) { |
| 849 | /* Link us to the previous in the chain */ |
| 850 | pIdentity->ch_next = pHandle->ch_prev; |
| 851 | /* Patch up the next link */ |
| 852 | m_Handles[pHandle->ch_prev].ch_next = 0; |
| 853 | } |
| 854 | /* Unlink case: We're in the middle! */ |
| 855 | else { |
| 856 | /* Patch the forward reference */ |
| 857 | m_Handles[pHandle->ch_next].ch_prev = pHandle->ch_prev; |
| 858 | /* Patch the backward reference */ |
| 859 | m_Handles[pHandle->ch_prev].ch_next = pHandle->ch_next; |
| 860 | } |
| 861 | |
| 862 | /* Lastly, decrease the reference count */ |
| 863 | pIdentity->refcount--; |
| 864 | } |
| 865 | |
| 866 | void HandleSystem::ReleasePrimHandle(unsigned int index) |
| 867 | { |
nothing calls this directly
no test coverage detected