Commit 43d0d85f authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

ole32: Use the standard list functions for the global interface table implementation.

parent c21f5c7c
......@@ -47,6 +47,7 @@
#include "compobj_private.h"
#include "wine/list.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(ole);
......@@ -65,8 +66,7 @@ typedef struct StdGITEntry
IID iid; /* IID of the interface */
IStream* stream; /* Holds the marshalled interface */
struct StdGITEntry* next;
struct StdGITEntry* prev;
struct list entry;
} StdGITEntry;
/* Class data */
......@@ -75,8 +75,7 @@ typedef struct StdGlobalInterfaceTableImpl
const IGlobalInterfaceTableVtbl *lpVtbl;
ULONG ref;
struct StdGITEntry* firstEntry;
struct StdGITEntry* lastEntry;
struct list list;
ULONG nextCookie;
} StdGlobalInterfaceTableImpl;
......@@ -116,13 +115,11 @@ StdGlobalInterfaceTable_FindEntry(IGlobalInterfaceTable* iface, DWORD cookie)
TRACE("iface=%p, cookie=0x%x\n", iface, (UINT)cookie);
EnterCriticalSection(&git_section);
e = self->firstEntry;
while (e != NULL) {
LIST_FOR_EACH_ENTRY(e, &self->list, StdGITEntry, entry) {
if (e->cookie == cookie) {
LeaveCriticalSection(&git_section);
return e;
}
e = e->next;
}
LeaveCriticalSection(&git_section);
......@@ -224,11 +221,7 @@ StdGlobalInterfaceTable_RegisterInterfaceInGlobal(
self->nextCookie++; /* inc the cookie count */
/* insert the new entry at the end of the list */
entry->next = NULL;
entry->prev = self->lastEntry;
if (entry->prev) entry->prev->next = entry;
else self->firstEntry = entry;
self->lastEntry = entry;
list_add_tail(&self->list, &entry->entry);
/* and return the cookie */
*pdwCookie = entry->cookie;
......@@ -243,7 +236,6 @@ static HRESULT WINAPI
StdGlobalInterfaceTable_RevokeInterfaceFromGlobal(
IGlobalInterfaceTable* iface, DWORD dwCookie)
{
StdGlobalInterfaceTableImpl* const self = (StdGlobalInterfaceTableImpl*) iface;
StdGITEntry* entry;
HRESULT hr;
......@@ -266,10 +258,7 @@ StdGlobalInterfaceTable_RevokeInterfaceFromGlobal(
/* chop entry out of the list, and free the memory */
EnterCriticalSection(&git_section);
if (entry->prev) entry->prev->next = entry->next;
else self->firstEntry = entry->next;
if (entry->next) entry->next->prev = entry->prev;
else self->lastEntry = entry->prev;
list_remove(&entry->entry);
LeaveCriticalSection(&git_section);
HeapFree(GetProcessHeap(), 0, entry);
......@@ -400,8 +389,7 @@ void* StdGlobalInterfaceTable_Construct(void)
newGIT->lpVtbl = &StdGlobalInterfaceTableImpl_Vtbl;
newGIT->ref = 1; /* Initialise the reference count */
newGIT->firstEntry = NULL; /* we start with an empty table */
newGIT->lastEntry = NULL;
list_init(&newGIT->list);
newGIT->nextCookie = 0xf100; /* that's where windows starts, so that's where we start */
TRACE("Created the GIT at %p\n", newGIT);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment