Commit 23884726 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Use list struct directly instead of ContextList wrapper.

parent 724754da
...@@ -110,23 +110,7 @@ void Context_CopyProperties(const void *to, const void *from) ...@@ -110,23 +110,7 @@ void Context_CopyProperties(const void *to, const void *from)
ContextPropertyList_Copy(toProperties, fromProperties); ContextPropertyList_Copy(toProperties, fromProperties);
} }
struct ContextList context_t *ContextList_Add(ContextList *list, CRITICAL_SECTION *cs, context_t *toLink,
{
struct list contexts;
};
struct ContextList *ContextList_Create(void)
{
struct ContextList *list = CryptMemAlloc(sizeof(struct ContextList));
if (list)
{
list_init(&list->contexts);
}
return list;
}
context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, context_t *toLink,
context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link) context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link)
{ {
context_t *context; context_t *context;
...@@ -148,13 +132,13 @@ context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, conte ...@@ -148,13 +132,13 @@ context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, conte
Context_Release(existing); Context_Release(existing);
} }
else else
list_add_head(&list->contexts, &context->u.entry); list_add_head(list, &context->u.entry);
LeaveCriticalSection(cs); LeaveCriticalSection(cs);
} }
return context; return context;
} }
context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, context_t *prev) context_t *ContextList_Enum(ContextList *list, CRITICAL_SECTION *cs, context_t *prev)
{ {
struct list *listNext; struct list *listNext;
context_t *ret; context_t *ret;
...@@ -162,11 +146,11 @@ context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, cont ...@@ -162,11 +146,11 @@ context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, cont
EnterCriticalSection(cs); EnterCriticalSection(cs);
if (prev) if (prev)
{ {
listNext = list_next(&list->contexts, &prev->u.entry); listNext = list_next(list, &prev->u.entry);
Context_Release(prev); Context_Release(prev);
} }
else else
listNext = list_next(&list->contexts, &list->contexts); listNext = list_next(list, list);
LeaveCriticalSection(cs); LeaveCriticalSection(cs);
if (listNext) if (listNext)
...@@ -179,7 +163,7 @@ context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, cont ...@@ -179,7 +163,7 @@ context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, cont
return ret; return ret;
} }
BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_t *context) BOOL ContextList_Remove(ContextList *list, CRITICAL_SECTION *cs, context_t *context)
{ {
BOOL inList = FALSE; BOOL inList = FALSE;
...@@ -195,20 +179,14 @@ BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_ ...@@ -195,20 +179,14 @@ BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_
return inList; return inList;
} }
static void ContextList_Empty(struct ContextList *list) void ContextList_Free(ContextList *list)
{ {
context_t *context, *next; context_t *context, *next;
LIST_FOR_EACH_ENTRY_SAFE(context, next, &list->contexts, context_t, u.entry) LIST_FOR_EACH_ENTRY_SAFE(context, next, list, context_t, u.entry)
{ {
TRACE("removing %p\n", context); TRACE("removing %p\n", context);
list_remove(&context->u.entry); list_remove(&context->u.entry);
Context_Release(context); Context_Release(context);
} }
} }
void ContextList_Free(struct ContextList *list)
{
ContextList_Empty(list);
CryptMemFree(list);
}
...@@ -436,22 +436,20 @@ void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN; ...@@ -436,22 +436,20 @@ void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
/** /**
* Context list functions. A context list is a simple list of link contexts. * Context list functions. A context list is a simple list of link contexts.
*/ */
struct ContextList; typedef struct list ContextList;
struct ContextList *ContextList_Create(void) DECLSPEC_HIDDEN; context_t *ContextList_Add(ContextList *list, CRITICAL_SECTION *cs, context_t *toLink, context_t *toReplace,
context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, context_t *toLink, context_t *toReplace,
struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN; struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN;
context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, context_t *prev) DECLSPEC_HIDDEN; context_t *ContextList_Enum(ContextList *list, CRITICAL_SECTION *cs, context_t *prev) DECLSPEC_HIDDEN;
/* Removes a context from the list. Returns TRUE if the context was removed, /* Removes a context from the list. Returns TRUE if the context was removed,
* or FALSE if not. (The context may have been duplicated, so subsequent * or FALSE if not. (The context may have been duplicated, so subsequent
* removes have no effect.) * removes have no effect.)
*/ */
BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_t *context) DECLSPEC_HIDDEN; BOOL ContextList_Remove(ContextList *list, CRITICAL_SECTION *cs, context_t *context) DECLSPEC_HIDDEN;
void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN; void ContextList_Free(ContextList *list) DECLSPEC_HIDDEN;
extern WINECRYPT_CERTSTORE empty_store; extern WINECRYPT_CERTSTORE empty_store;
void init_empty_store(void) DECLSPEC_HIDDEN; void init_empty_store(void) DECLSPEC_HIDDEN;
......
...@@ -83,9 +83,9 @@ typedef struct _WINE_MEMSTORE ...@@ -83,9 +83,9 @@ typedef struct _WINE_MEMSTORE
{ {
WINECRYPT_CERTSTORE hdr; WINECRYPT_CERTSTORE hdr;
CRITICAL_SECTION cs; CRITICAL_SECTION cs;
struct ContextList *certs; struct list certs;
struct ContextList *crls; struct list crls;
struct ContextList *ctls; struct list ctls;
} WINE_MEMSTORE; } WINE_MEMSTORE;
void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags, CertStoreType type, const store_vtbl_t *vtbl) void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags, CertStoreType type, const store_vtbl_t *vtbl)
...@@ -151,7 +151,7 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert, ...@@ -151,7 +151,7 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext); TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
context = ContextList_Add(ms->certs, &ms->cs, cert, toReplace, store, use_link); context = ContextList_Add(&ms->certs, &ms->cs, cert, toReplace, store, use_link);
if (!context) if (!context)
return FALSE; return FALSE;
...@@ -169,7 +169,7 @@ static context_t *MemStore_enumCert(WINECRYPT_CERTSTORE *store, context_t *prev) ...@@ -169,7 +169,7 @@ static context_t *MemStore_enumCert(WINECRYPT_CERTSTORE *store, context_t *prev)
TRACE("(%p, %p)\n", store, prev); TRACE("(%p, %p)\n", store, prev);
ret = ContextList_Enum(ms->certs, &ms->cs, prev); ret = ContextList_Enum(&ms->certs, &ms->cs, prev);
if (!ret) if (!ret)
SetLastError(CRYPT_E_NOT_FOUND); SetLastError(CRYPT_E_NOT_FOUND);
...@@ -181,7 +181,7 @@ static BOOL MemStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context) ...@@ -181,7 +181,7 @@ static BOOL MemStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context)
{ {
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
if (ContextList_Remove(ms->certs, &ms->cs, context)) if (ContextList_Remove(&ms->certs, &ms->cs, context))
Context_Release(context); Context_Release(context);
return TRUE; return TRUE;
...@@ -195,7 +195,7 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl, ...@@ -195,7 +195,7 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext); TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
context = ContextList_Add(ms->crls, &ms->cs, crl, toReplace, store, use_link); context = ContextList_Add(&ms->crls, &ms->cs, crl, toReplace, store, use_link);
if (!context) if (!context)
return FALSE; return FALSE;
...@@ -213,7 +213,7 @@ static context_t *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, context_t *prev) ...@@ -213,7 +213,7 @@ static context_t *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, context_t *prev)
TRACE("(%p, %p)\n", store, prev); TRACE("(%p, %p)\n", store, prev);
ret = ContextList_Enum(ms->crls, &ms->cs, prev); ret = ContextList_Enum(&ms->crls, &ms->cs, prev);
if (!ret) if (!ret)
SetLastError(CRYPT_E_NOT_FOUND); SetLastError(CRYPT_E_NOT_FOUND);
...@@ -225,7 +225,7 @@ static BOOL MemStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *context) ...@@ -225,7 +225,7 @@ static BOOL MemStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *context)
{ {
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
if (!ContextList_Remove(ms->crls, &ms->cs, context)) if (!ContextList_Remove(&ms->crls, &ms->cs, context))
Context_Release(context); Context_Release(context);
return TRUE; return TRUE;
...@@ -239,7 +239,7 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl, ...@@ -239,7 +239,7 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext); TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
context = ContextList_Add(ms->ctls, &ms->cs, ctl, toReplace, store, use_link); context = ContextList_Add(&ms->ctls, &ms->cs, ctl, toReplace, store, use_link);
if (!context) if (!context)
return FALSE; return FALSE;
...@@ -257,7 +257,7 @@ static context_t *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, context_t *prev) ...@@ -257,7 +257,7 @@ static context_t *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, context_t *prev)
TRACE("(%p, %p)\n", store, prev); TRACE("(%p, %p)\n", store, prev);
ret = ContextList_Enum(ms->ctls, &ms->cs, prev); ret = ContextList_Enum(&ms->ctls, &ms->cs, prev);
if (!ret) if (!ret)
SetLastError(CRYPT_E_NOT_FOUND); SetLastError(CRYPT_E_NOT_FOUND);
...@@ -269,7 +269,7 @@ static BOOL MemStore_deleteCTL(WINECRYPT_CERTSTORE *store, context_t *context) ...@@ -269,7 +269,7 @@ static BOOL MemStore_deleteCTL(WINECRYPT_CERTSTORE *store, context_t *context)
{ {
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
if (!ContextList_Remove(ms->ctls, &ms->cs, context)) if (!ContextList_Remove(&ms->ctls, &ms->cs, context))
Context_Release(context); Context_Release(context);
return TRUE; return TRUE;
...@@ -294,9 +294,9 @@ static DWORD MemStore_release(WINECRYPT_CERTSTORE *cert_store, DWORD flags) ...@@ -294,9 +294,9 @@ static DWORD MemStore_release(WINECRYPT_CERTSTORE *cert_store, DWORD flags)
if(ref) if(ref)
return (flags & CERT_CLOSE_STORE_CHECK_FLAG) ? CRYPT_E_PENDING_CLOSE : ERROR_SUCCESS; return (flags & CERT_CLOSE_STORE_CHECK_FLAG) ? CRYPT_E_PENDING_CLOSE : ERROR_SUCCESS;
ContextList_Free(store->certs); ContextList_Free(&store->certs);
ContextList_Free(store->crls); ContextList_Free(&store->crls);
ContextList_Free(store->ctls); ContextList_Free(&store->ctls);
store->cs.DebugInfo->Spare[0] = 0; store->cs.DebugInfo->Spare[0] = 0;
DeleteCriticalSection(&store->cs); DeleteCriticalSection(&store->cs);
CRYPT_FreeStore(&store->hdr); CRYPT_FreeStore(&store->hdr);
...@@ -350,9 +350,9 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv, ...@@ -350,9 +350,9 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem, &MemStoreVtbl); CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem, &MemStoreVtbl);
InitializeCriticalSection(&store->cs); InitializeCriticalSection(&store->cs);
store->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ContextList.cs"); store->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ContextList.cs");
store->certs = ContextList_Create(); list_init(&store->certs);
store->crls = ContextList_Create(); list_init(&store->crls);
store->ctls = ContextList_Create(); list_init(&store->ctls);
/* Mem store doesn't need crypto provider, so close it */ /* Mem store doesn't need crypto provider, so close it */
if (hCryptProv && !(dwFlags & CERT_STORE_NO_CRYPT_RELEASE_FLAG)) if (hCryptProv && !(dwFlags & CERT_STORE_NO_CRYPT_RELEASE_FLAG))
CryptReleaseContext(hCryptProv, 0); CryptReleaseContext(hCryptProv, 0);
......
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