| 14707 | |
| 14708 | |
| 14709 | MsgMonitorStruct *MsgMonitorList::AddInternal(UINT aMsg, bool aAppend) |
| 14710 | { |
| 14711 | if (mCount == mCountMax) |
| 14712 | { |
| 14713 | int new_count = mCountMax ? mCountMax * mCountMax : 16; |
| 14714 | void *new_array = realloc(mMonitor, new_count * sizeof(MsgMonitorStruct)); |
| 14715 | if (!new_array) |
| 14716 | return NULL; |
| 14717 | mMonitor = (MsgMonitorStruct *)new_array; |
| 14718 | mCountMax = new_count; |
| 14719 | } |
| 14720 | MsgMonitorStruct *new_mon; |
| 14721 | if (!aAppend) |
| 14722 | { |
| 14723 | for (MsgMonitorInstance *inst = mTop; inst; inst = inst->previous) |
| 14724 | { |
| 14725 | inst->index++; // Correct the index of each running monitor. |
| 14726 | inst->count++; // Iterate the same set of items which existed before. |
| 14727 | // By contrast, count isn't adjusted when adding at the end because we do not |
| 14728 | // want new items to be called by messages received before they were registered. |
| 14729 | } |
| 14730 | // Shift existing items to make room. |
| 14731 | memmove(mMonitor + 1, mMonitor, mCount * sizeof(MsgMonitorStruct)); |
| 14732 | new_mon = mMonitor; |
| 14733 | } |
| 14734 | else |
| 14735 | new_mon = mMonitor + mCount; |
| 14736 | |
| 14737 | ++mCount; |
| 14738 | new_mon->msg = aMsg; |
| 14739 | new_mon->msg_type = 0; // Must be initialised to 0 for all callers except GUI. |
| 14740 | // These are initialised by OnMessage, since OnExit and OnClipboardChange don't use them: |
| 14741 | //new_mon->instance_count = 0; |
| 14742 | //new_mon->max_instances = 1; |
| 14743 | return new_mon; |
| 14744 | } |
| 14745 | |
| 14746 | |
| 14747 | MsgMonitorStruct *MsgMonitorList::Add(UINT aMsg, IObject *aCallback, bool aAppend) |
nothing calls this directly
no outgoing calls
no test coverage detected