Module: wine Branch: master Commit: 06f5ee4b2cc7fca44dd32bc1b6d5db1dd11b92f9 URL: http://source.winehq.org/git/wine.git/?a=commit;h=06f5ee4b2cc7fca44dd32bc1b6...
Author: Jacek Caban jacek@codeweavers.com Date: Tue Oct 15 16:53:11 2013 +0200
crypt32: Store list entry directly in context_t.
---
dlls/crypt32/collectionstore.c | 1 - dlls/crypt32/context.c | 65 ++++++++++++--------------------------- dlls/crypt32/crl.c | 2 +- dlls/crypt32/crypt32_private.h | 5 +++ dlls/crypt32/provstore.c | 1 - dlls/crypt32/regstore.c | 1 - dlls/crypt32/store.c | 1 - 7 files changed, 26 insertions(+), 50 deletions(-)
diff --git a/dlls/crypt32/collectionstore.c b/dlls/crypt32/collectionstore.c index dbcf21b..284519f 100644 --- a/dlls/crypt32/collectionstore.c +++ b/dlls/crypt32/collectionstore.c @@ -20,7 +20,6 @@ #include "winbase.h" #include "wincrypt.h" #include "wine/debug.h" -#include "wine/list.h" #include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index b2b2282..527eb79 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -21,7 +21,6 @@ #include "winbase.h" #include "wincrypt.h" #include "wine/debug.h" -#include "wine/list.h" #include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(context); @@ -163,50 +162,30 @@ struct ContextList *ContextList_Create( return list; }
-static inline struct list *ContextList_ContextToEntry(const struct ContextList *list, - const void *context) -{ - struct list *ret; - - if (context) - ret = Context_GetExtra(context, list->contextSize); - else - ret = NULL; - return ret; -} - -static inline void *ContextList_EntryToContext(const struct ContextList *list, - struct list *entry) -{ - return (LPBYTE)entry - list->contextSize; -} - void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace) { context_t *context;
TRACE("(%p, %p, %p)\n", list, toLink, toReplace);
- context = Context_CreateLinkContext(list->contextSize, context_from_ptr(toLink), sizeof(struct list)); + context = Context_CreateLinkContext(list->contextSize, context_from_ptr(toLink), 0); if (context) { - struct list *entry = ContextList_ContextToEntry(list, CONTEXT_FROM_BASE_CONTEXT(context)); - TRACE("adding %p\n", context); EnterCriticalSection(&list->cs); if (toReplace) { - struct list *existing = ContextList_ContextToEntry(list, toReplace); + context_t *existing = context_from_ptr(toReplace);
- entry->prev = existing->prev; - entry->next = existing->next; - entry->prev->next = entry; - entry->next->prev = entry; - existing->prev = existing->next = existing; + context->u.entry.prev = existing->u.entry.prev; + context->u.entry.next = existing->u.entry.next; + context->u.entry.prev->next = &context->u.entry; + context->u.entry.next->prev = &context->u.entry; + list_init(&existing->u.entry); Context_Release(context_from_ptr(toReplace)); } else - list_add_head(&list->contexts, entry); + list_add_head(&list->contexts, &context->u.entry); LeaveCriticalSection(&list->cs); } return CONTEXT_FROM_BASE_CONTEXT(context); @@ -220,9 +199,7 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev) EnterCriticalSection(&list->cs); if (pPrev) { - struct list *prevEntry = ContextList_ContextToEntry(list, pPrev); - - listNext = list_next(&list->contexts, prevEntry); + listNext = list_next(&list->contexts, &context_from_ptr(pPrev)->u.entry); Context_Release(context_from_ptr(pPrev)); } else @@ -231,7 +208,7 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev)
if (listNext) { - ret = ContextList_EntryToContext(list, listNext); + ret = CONTEXT_FROM_BASE_CONTEXT(LIST_ENTRY(listNext, context_t, u.entry)); Context_AddRef(context_from_ptr(ret)); } else @@ -239,35 +216,33 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev) return ret; }
-BOOL ContextList_Remove(struct ContextList *list, void *context) +BOOL ContextList_Remove(struct ContextList *list, void *ctx) { - struct list *entry = ContextList_ContextToEntry(list, context); + context_t *context = context_from_ptr(ctx); BOOL inList = FALSE;
EnterCriticalSection(&list->cs); - if (!list_empty(entry)) + if (!list_empty(&context->u.entry)) { - list_remove(entry); + list_remove(&context->u.entry); + list_init(&context->u.entry); inList = TRUE; } LeaveCriticalSection(&list->cs); - if (inList) - list_init(entry); + return inList; }
static void ContextList_Empty(struct ContextList *list) { - struct list *entry, *next; + context_t *context, *next;
EnterCriticalSection(&list->cs); - LIST_FOR_EACH_SAFE(entry, next, &list->contexts) + LIST_FOR_EACH_ENTRY_SAFE(context, next, &list->contexts, context_t, u.entry) { - const void *context = ContextList_EntryToContext(list, entry); - TRACE("removing %p\n", context); - list_remove(entry); - Context_Release(context_from_ptr(context)); + list_remove(&context->u.entry); + Context_Release(context); } LeaveCriticalSection(&list->cs); } diff --git a/dlls/crypt32/crl.c b/dlls/crypt32/crl.c index 9ecc23f..2e3a58f 100644 --- a/dlls/crypt32/crl.c +++ b/dlls/crypt32/crl.c @@ -343,7 +343,7 @@ PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext) return pCrlContext; }
-BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext) +BOOL WINAPI CertFreeCRLContext(PCCRL_CONTEXT pCrlContext) { BOOL ret = TRUE;
diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 287e0c2..20ba276 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -19,6 +19,8 @@ #ifndef __CRYPT32_PRIVATE_H__ #define __CRYPT32_PRIVATE_H__
+#include "wine/list.h" + /* a few asn.1 tags we need */ #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) @@ -170,6 +172,9 @@ typedef struct _context_t { LONG ref; struct _context_t *linked; CONTEXT_PROPERTY_LIST *properties; + union { + struct list entry; + } u; } BASE_CONTEXT;
static inline context_t *context_from_ptr(const void *ptr) diff --git a/dlls/crypt32/provstore.c b/dlls/crypt32/provstore.c index 97b5454..ce9c145 100644 --- a/dlls/crypt32/provstore.c +++ b/dlls/crypt32/provstore.c @@ -20,7 +20,6 @@ #include "winbase.h" #include "wincrypt.h" #include "wine/debug.h" -#include "wine/list.h" #include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dlls/crypt32/regstore.c b/dlls/crypt32/regstore.c index 8fb7eeb..b79387f 100644 --- a/dlls/crypt32/regstore.c +++ b/dlls/crypt32/regstore.c @@ -23,7 +23,6 @@ #include "winreg.h" #include "winuser.h" #include "wine/debug.h" -#include "wine/list.h" #include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt); diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 5bd19eb..3dfb850 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -35,7 +35,6 @@ #include "winuser.h" #include "wincrypt.h" #include "wine/debug.h" -#include "wine/list.h" #include "wine/exception.h" #include "crypt32_private.h"