Commit 8d4b288f authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Use context_t in ContextList_Add.

parent 6eddbf18
......@@ -137,33 +137,31 @@ struct ContextList *ContextList_Create(
return list;
}
void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace, struct WINE_CRYPTCERTSTORE *store, BOOL use_link)
context_t *ContextList_Add(struct ContextList *list, context_t *toLink, context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link)
{
context_t *context;
TRACE("(%p, %p, %p)\n", list, toLink, toReplace);
TRACE("(%p, %p, %p)\n", list, toLink, existing);
context = context_from_ptr(toLink)->vtbl->clone(BASE_CONTEXT_FROM_CONTEXT(toLink), store, use_link);
context = toLink->vtbl->clone(toLink, store, use_link);
if (context)
{
TRACE("adding %p\n", context);
EnterCriticalSection(&list->cs);
if (toReplace)
if (existing)
{
context_t *existing = context_from_ptr(toReplace);
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));
Context_Release(existing);
}
else
list_add_head(&list->contexts, &context->u.entry);
LeaveCriticalSection(&list->cs);
}
return CONTEXT_FROM_BASE_CONTEXT(context);
return context;
}
void *ContextList_Enum(struct ContextList *list, void *pPrev)
......
......@@ -444,7 +444,7 @@ struct ContextList;
struct ContextList *ContextList_Create(
const WINE_CONTEXT_INTERFACE *contextInterface, size_t contextSize) DECLSPEC_HIDDEN;
void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace,
context_t *ContextList_Add(struct ContextList *list, context_t *toLink, context_t *toReplace,
struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN;
void *ContextList_Enum(struct ContextList *list, void *pPrev) DECLSPEC_HIDDEN;
......
......@@ -146,16 +146,18 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, void *cert,
void *toReplace, const void **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
PCERT_CONTEXT context;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
context = ContextList_Add(ms->certs, cert, toReplace, store, use_link);
context = ContextList_Add(ms->certs, context_from_ptr(cert), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link);
if (!context)
return FALSE;
if (ppStoreContext)
*ppStoreContext = CertDuplicateCertificateContext(context);
if (ppStoreContext) {
Context_AddRef(context);
*ppStoreContext = context_ptr(context);
}
return TRUE;
}
......@@ -188,16 +190,18 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
void *toReplace, const void **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
PCRL_CONTEXT context;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
context = ContextList_Add(ms->crls, crl, toReplace, store, use_link);
context = ContextList_Add(ms->crls, context_from_ptr(crl), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link);
if (!context)
return FALSE;
if (ppStoreContext)
*ppStoreContext = CertDuplicateCRLContext(context);
if (ppStoreContext) {
Context_AddRef(context);
*ppStoreContext = context_ptr(context);
}
return TRUE;
}
......@@ -230,16 +234,18 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
void *toReplace, const void **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
PCTL_CONTEXT context;
context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
context = ContextList_Add(ms->ctls, ctl, toReplace, store, use_link);
context = ContextList_Add(ms->ctls, context_from_ptr(ctl), toReplace ? context_from_ptr(toReplace) : NULL, store, use_link);
if (!context)
return FALSE;
if (ppStoreContext)
*ppStoreContext = CertDuplicateCTLContext(context);
if (ppStoreContext) {
Context_AddRef(context);
*ppStoreContext = context_ptr(context);
}
return TRUE;
}
......
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