Commit 22cc5471 authored by Andrew Eikum's avatar Andrew Eikum Committed by Alexandre Julliard

oleaut32: Convert ITypeLibImpl to use standard linked list.

parent 3d03a5e2
...@@ -1010,7 +1010,7 @@ typedef struct tagITypeLibImpl ...@@ -1010,7 +1010,7 @@ typedef struct tagITypeLibImpl
/* typelibs are cached, keyed by path and index, so store the linked list info within them */ /* typelibs are cached, keyed by path and index, so store the linked list info within them */
struct tagITypeLibImpl *next, *prev; struct list entry;
WCHAR *path; WCHAR *path;
INT index; INT index;
} ITypeLibImpl; } ITypeLibImpl;
...@@ -2443,7 +2443,7 @@ static ITypeInfoImpl * MSFT_DoTypeInfo( ...@@ -2443,7 +2443,7 @@ static ITypeInfoImpl * MSFT_DoTypeInfo(
* place. This will cause a deliberate memory leak, but generally losing RAM for cycles is an acceptable * place. This will cause a deliberate memory leak, but generally losing RAM for cycles is an acceptable
* tradeoff here. * tradeoff here.
*/ */
static ITypeLibImpl *tlb_cache_first; static struct list tlb_cache = LIST_INIT(tlb_cache);
static CRITICAL_SECTION cache_section; static CRITICAL_SECTION cache_section;
static CRITICAL_SECTION_DEBUG cache_section_debug = static CRITICAL_SECTION_DEBUG cache_section_debug =
{ {
...@@ -2905,7 +2905,7 @@ static HRESULT TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath ...@@ -2905,7 +2905,7 @@ static HRESULT TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath
/* We look the path up in the typelib cache. If found, we just addref it, and return the pointer. */ /* We look the path up in the typelib cache. If found, we just addref it, and return the pointer. */
EnterCriticalSection(&cache_section); EnterCriticalSection(&cache_section);
for (entry = tlb_cache_first; entry != NULL; entry = entry->next) LIST_FOR_EACH_ENTRY(entry, &tlb_cache, ITypeLibImpl, entry)
{ {
if (!strcmpiW(entry->path, pszPath) && entry->index == index) if (!strcmpiW(entry->path, pszPath) && entry->index == index)
{ {
...@@ -2956,9 +2956,7 @@ static HRESULT TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath ...@@ -2956,9 +2956,7 @@ static HRESULT TLB_ReadTypeLib(LPCWSTR pszFileName, LPWSTR pszPath, UINT cchPath
/* FIXME: check if it has added already in the meantime */ /* FIXME: check if it has added already in the meantime */
EnterCriticalSection(&cache_section); EnterCriticalSection(&cache_section);
if ((impl->next = tlb_cache_first) != NULL) impl->next->prev = impl; list_add_head(&tlb_cache, &impl->entry);
impl->prev = NULL;
tlb_cache_first = impl;
LeaveCriticalSection(&cache_section); LeaveCriticalSection(&cache_section);
ret = S_OK; ret = S_OK;
} else } else
...@@ -4255,9 +4253,8 @@ static ULONG WINAPI ITypeLib2_fnRelease( ITypeLib2 *iface) ...@@ -4255,9 +4253,8 @@ static ULONG WINAPI ITypeLib2_fnRelease( ITypeLib2 *iface)
{ {
TRACE("removing from cache list\n"); TRACE("removing from cache list\n");
EnterCriticalSection(&cache_section); EnterCriticalSection(&cache_section);
if (This->next) This->next->prev = This->prev; if(This->entry.next)
if (This->prev) This->prev->next = This->next; list_remove(&This->entry);
else tlb_cache_first = This->next;
LeaveCriticalSection(&cache_section); LeaveCriticalSection(&cache_section);
heap_free(This->path); heap_free(This->path);
} }
......
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