crypt32: Use context_t in ContextList_Add.

This commit is contained in:
Jacek Caban 2013-10-17 11:07:38 +02:00 committed by Alexandre Julliard
parent 6eddbf18ca
commit 8d4b288f59
3 changed files with 25 additions and 21 deletions

View File

@ -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)

View File

@ -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;

View File

@ -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;
}