Commit 06f5ee4b authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Store list entry directly in context_t.

parent 988e8a78
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "winbase.h" #include "winbase.h"
#include "wincrypt.h" #include "wincrypt.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h"
#include "crypt32_private.h" #include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt); WINE_DEFAULT_DEBUG_CHANNEL(crypt);
......
...@@ -21,7 +21,6 @@ ...@@ -21,7 +21,6 @@
#include "winbase.h" #include "winbase.h"
#include "wincrypt.h" #include "wincrypt.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h"
#include "crypt32_private.h" #include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(context); WINE_DEFAULT_DEBUG_CHANNEL(context);
...@@ -163,50 +162,30 @@ struct ContextList *ContextList_Create( ...@@ -163,50 +162,30 @@ struct ContextList *ContextList_Create(
return list; 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) void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace)
{ {
context_t *context; context_t *context;
TRACE("(%p, %p, %p)\n", list, toLink, toReplace); 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) if (context)
{ {
struct list *entry = ContextList_ContextToEntry(list, CONTEXT_FROM_BASE_CONTEXT(context));
TRACE("adding %p\n", context); TRACE("adding %p\n", context);
EnterCriticalSection(&list->cs); EnterCriticalSection(&list->cs);
if (toReplace) if (toReplace)
{ {
struct list *existing = ContextList_ContextToEntry(list, toReplace); context_t *existing = context_from_ptr(toReplace);
entry->prev = existing->prev; context->u.entry.prev = existing->u.entry.prev;
entry->next = existing->next; context->u.entry.next = existing->u.entry.next;
entry->prev->next = entry; context->u.entry.prev->next = &context->u.entry;
entry->next->prev = entry; context->u.entry.next->prev = &context->u.entry;
existing->prev = existing->next = existing; list_init(&existing->u.entry);
Context_Release(context_from_ptr(toReplace)); Context_Release(context_from_ptr(toReplace));
} }
else else
list_add_head(&list->contexts, entry); list_add_head(&list->contexts, &context->u.entry);
LeaveCriticalSection(&list->cs); LeaveCriticalSection(&list->cs);
} }
return CONTEXT_FROM_BASE_CONTEXT(context); return CONTEXT_FROM_BASE_CONTEXT(context);
...@@ -220,9 +199,7 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev) ...@@ -220,9 +199,7 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev)
EnterCriticalSection(&list->cs); EnterCriticalSection(&list->cs);
if (pPrev) if (pPrev)
{ {
struct list *prevEntry = ContextList_ContextToEntry(list, pPrev); listNext = list_next(&list->contexts, &context_from_ptr(pPrev)->u.entry);
listNext = list_next(&list->contexts, prevEntry);
Context_Release(context_from_ptr(pPrev)); Context_Release(context_from_ptr(pPrev));
} }
else else
...@@ -231,7 +208,7 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev) ...@@ -231,7 +208,7 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev)
if (listNext) 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)); Context_AddRef(context_from_ptr(ret));
} }
else else
...@@ -239,35 +216,33 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev) ...@@ -239,35 +216,33 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev)
return ret; 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; BOOL inList = FALSE;
EnterCriticalSection(&list->cs); 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; inList = TRUE;
} }
LeaveCriticalSection(&list->cs); LeaveCriticalSection(&list->cs);
if (inList)
list_init(entry);
return inList; return inList;
} }
static void ContextList_Empty(struct ContextList *list) static void ContextList_Empty(struct ContextList *list)
{ {
struct list *entry, *next; context_t *context, *next;
EnterCriticalSection(&list->cs); 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); TRACE("removing %p\n", context);
list_remove(entry); list_remove(&context->u.entry);
Context_Release(context_from_ptr(context)); Context_Release(context);
} }
LeaveCriticalSection(&list->cs); LeaveCriticalSection(&list->cs);
} }
......
...@@ -343,7 +343,7 @@ PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext) ...@@ -343,7 +343,7 @@ PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext)
return pCrlContext; return pCrlContext;
} }
BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext) BOOL WINAPI CertFreeCRLContext(PCCRL_CONTEXT pCrlContext)
{ {
BOOL ret = TRUE; BOOL ret = TRUE;
......
...@@ -19,6 +19,8 @@ ...@@ -19,6 +19,8 @@
#ifndef __CRYPT32_PRIVATE_H__ #ifndef __CRYPT32_PRIVATE_H__
#define __CRYPT32_PRIVATE_H__ #define __CRYPT32_PRIVATE_H__
#include "wine/list.h"
/* a few asn.1 tags we need */ /* a few asn.1 tags we need */
#define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01) #define ASN_BOOL (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x01)
#define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03) #define ASN_BITSTRING (ASN_UNIVERSAL | ASN_PRIMITIVE | 0x03)
...@@ -170,6 +172,9 @@ typedef struct _context_t { ...@@ -170,6 +172,9 @@ typedef struct _context_t {
LONG ref; LONG ref;
struct _context_t *linked; struct _context_t *linked;
CONTEXT_PROPERTY_LIST *properties; CONTEXT_PROPERTY_LIST *properties;
union {
struct list entry;
} u;
} BASE_CONTEXT; } BASE_CONTEXT;
static inline context_t *context_from_ptr(const void *ptr) static inline context_t *context_from_ptr(const void *ptr)
......
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
#include "winbase.h" #include "winbase.h"
#include "wincrypt.h" #include "wincrypt.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h"
#include "crypt32_private.h" #include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt); WINE_DEFAULT_DEBUG_CHANNEL(crypt);
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include "winreg.h" #include "winreg.h"
#include "winuser.h" #include "winuser.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h"
#include "crypt32_private.h" #include "crypt32_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(crypt); WINE_DEFAULT_DEBUG_CHANNEL(crypt);
......
...@@ -35,7 +35,6 @@ ...@@ -35,7 +35,6 @@
#include "winuser.h" #include "winuser.h"
#include "wincrypt.h" #include "wincrypt.h"
#include "wine/debug.h" #include "wine/debug.h"
#include "wine/list.h"
#include "wine/exception.h" #include "wine/exception.h"
#include "crypt32_private.h" #include "crypt32_private.h"
......
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