| 14774 | |
| 14775 | |
| 14776 | void MsgMonitorList::Delete(MsgMonitorStruct *aMonitor) |
| 14777 | { |
| 14778 | ASSERT(aMonitor >= mMonitor && aMonitor < mMonitor + mCount); |
| 14779 | |
| 14780 | int mon_index = int(aMonitor - mMonitor); |
| 14781 | // Adjust the index of any active message monitors affected by this deletion. This allows a |
| 14782 | // message monitor to delete older message monitors while still allowing any remaining monitors |
| 14783 | // of that message to be called (when there are multiple). |
| 14784 | for (MsgMonitorInstance *inst = mTop; inst; inst = inst->previous) |
| 14785 | { |
| 14786 | inst->Delete(mon_index); |
| 14787 | } |
| 14788 | // Remove the item from the array. |
| 14789 | --mCount; // Must be done prior to the below. |
| 14790 | LPVOID release_me = aMonitor->union_value; |
| 14791 | bool is_method = aMonitor->is_method; |
| 14792 | if (mon_index < mCount) // An element other than the last is being removed. Shift the array to cover/delete it. |
| 14793 | memmove(aMonitor, aMonitor + 1, (mCount - mon_index) * sizeof(MsgMonitorStruct)); |
| 14794 | if (is_method) |
| 14795 | free(release_me); |
| 14796 | else |
| 14797 | reinterpret_cast<IObject *>(release_me)->Release(); // Must be called last in case it calls a __delete() meta-function. |
| 14798 | } |
| 14799 | |
| 14800 | |
| 14801 | BOOL MsgMonitorList::IsMonitoring(UINT aMsg, UCHAR aMsgType) |