Module: wine Branch: master Commit: a27da35b0540bd6a45adb27c880d89c16b8df2dd URL: http://source.winehq.org/git/wine.git/?a=commit;h=a27da35b0540bd6a45adb27c88...
Author: Jacek Caban jacek@codeweavers.com Date: Wed May 4 19:41:13 2016 +0200
msctf: Moved thread manager's sink list destructor implementation into a more generic helper.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/msctf/msctf.c | 9 +++++++++ dlls/msctf/msctf_internal.h | 1 + dlls/msctf/threadmgr.c | 49 ++++++--------------------------------------- 3 files changed, 16 insertions(+), 43 deletions(-)
diff --git a/dlls/msctf/msctf.c b/dlls/msctf/msctf.c index 81f01dc..a47f16c 100644 --- a/dlls/msctf/msctf.c +++ b/dlls/msctf/msctf.c @@ -323,6 +323,15 @@ HRESULT unadvise_sink(DWORD cookie) return S_OK; }
+void free_sinks(struct list *sink_list) +{ + while(!list_empty(sink_list)) + { + Sink* sink = LIST_ENTRY(sink_list->next, Sink, entry); + free_sink(sink); + } +} + /***************************************************************************** * Active Text Service Management *****************************************************************************/ diff --git a/dlls/msctf/msctf_internal.h b/dlls/msctf/msctf_internal.h index fc41de5..e4da480 100644 --- a/dlls/msctf/msctf_internal.h +++ b/dlls/msctf/msctf_internal.h @@ -77,6 +77,7 @@ typedef struct {
HRESULT advise_sink(struct list *sink_list, REFIID riid, DWORD cookie_magic, IUnknown *unk, DWORD *cookie) DECLSPEC_HIDDEN; HRESULT unadvise_sink(DWORD cookie) DECLSPEC_HIDDEN; +void free_sinks(struct list *sink_list) DECLSPEC_HIDDEN;
extern const WCHAR szwSystemTIPKey[] DECLSPEC_HIDDEN; extern const WCHAR szwSystemCTFKey[] DECLSPEC_HIDDEN; diff --git a/dlls/msctf/threadmgr.c b/dlls/msctf/threadmgr.c index bface5d..62508b9 100644 --- a/dlls/msctf/threadmgr.c +++ b/dlls/msctf/threadmgr.c @@ -157,12 +157,6 @@ static inline EnumTfDocumentMgr *impl_from_IEnumTfDocumentMgrs(IEnumTfDocumentMg return CONTAINING_RECORD(iface, EnumTfDocumentMgr, IEnumTfDocumentMgrs_iface); }
-static void free_sink(Sink *sink) -{ - IUnknown_Release(sink->interfaces.pIUnknown); - HeapFree(GetProcessHeap(),0,sink); -} - static void ThreadMgr_Destructor(ThreadMgr *This) { struct list *cursor, *cursor2; @@ -176,43 +170,12 @@ static void ThreadMgr_Destructor(ThreadMgr *This) if (This->focus) ITfDocumentMgr_Release(This->focus);
- /* free sinks */ - LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ActiveLanguageProfileNotifySink) - { - Sink* sink = LIST_ENTRY(cursor,Sink,entry); - list_remove(cursor); - free_sink(sink); - } - LIST_FOR_EACH_SAFE(cursor, cursor2, &This->DisplayAttributeNotifySink) - { - Sink* sink = LIST_ENTRY(cursor,Sink,entry); - list_remove(cursor); - free_sink(sink); - } - LIST_FOR_EACH_SAFE(cursor, cursor2, &This->KeyTraceEventSink) - { - Sink* sink = LIST_ENTRY(cursor,Sink,entry); - list_remove(cursor); - free_sink(sink); - } - LIST_FOR_EACH_SAFE(cursor, cursor2, &This->PreservedKeyNotifySink) - { - Sink* sink = LIST_ENTRY(cursor,Sink,entry); - list_remove(cursor); - free_sink(sink); - } - LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadFocusSink) - { - Sink* sink = LIST_ENTRY(cursor,Sink,entry); - list_remove(cursor); - free_sink(sink); - } - LIST_FOR_EACH_SAFE(cursor, cursor2, &This->ThreadMgrEventSink) - { - Sink* sink = LIST_ENTRY(cursor,Sink,entry); - list_remove(cursor); - free_sink(sink); - } + free_sinks(&This->ActiveLanguageProfileNotifySink); + free_sinks(&This->DisplayAttributeNotifySink); + free_sinks(&This->KeyTraceEventSink); + free_sinks(&This->PreservedKeyNotifySink); + free_sinks(&This->ThreadFocusSink); + free_sinks(&This->ThreadMgrEventSink);
LIST_FOR_EACH_SAFE(cursor, cursor2, &This->CurrentPreservedKeys) {