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; 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; 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) if (context)
{ {
TRACE("adding %p\n", context); TRACE("adding %p\n", context);
EnterCriticalSection(&list->cs); 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.prev = existing->u.entry.prev;
context->u.entry.next = existing->u.entry.next; context->u.entry.next = existing->u.entry.next;
context->u.entry.prev->next = &context->u.entry; context->u.entry.prev->next = &context->u.entry;
context->u.entry.next->prev = &context->u.entry; context->u.entry.next->prev = &context->u.entry;
list_init(&existing->u.entry); list_init(&existing->u.entry);
Context_Release(context_from_ptr(toReplace)); Context_Release(existing);
} }
else else
list_add_head(&list->contexts, &context->u.entry); list_add_head(&list->contexts, &context->u.entry);
LeaveCriticalSection(&list->cs); LeaveCriticalSection(&list->cs);
} }
return CONTEXT_FROM_BASE_CONTEXT(context); return context;
} }
void *ContextList_Enum(struct ContextList *list, void *pPrev) void *ContextList_Enum(struct ContextList *list, void *pPrev)

View File

@ -444,7 +444,7 @@ struct ContextList;
struct ContextList *ContextList_Create( struct ContextList *ContextList_Create(
const WINE_CONTEXT_INTERFACE *contextInterface, size_t contextSize) DECLSPEC_HIDDEN; 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; struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN;
void *ContextList_Enum(struct ContextList *list, void *pPrev) 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) void *toReplace, const void **ppStoreContext, BOOL use_link)
{ {
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
PCERT_CONTEXT context; context_t *context;
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, 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) if (!context)
return FALSE; return FALSE;
if (ppStoreContext) if (ppStoreContext) {
*ppStoreContext = CertDuplicateCertificateContext(context); Context_AddRef(context);
*ppStoreContext = context_ptr(context);
}
return TRUE; return TRUE;
} }
@ -188,16 +190,18 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
void *toReplace, const void **ppStoreContext, BOOL use_link) void *toReplace, const void **ppStoreContext, BOOL use_link)
{ {
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
PCRL_CONTEXT context; context_t *context;
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, 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) if (!context)
return FALSE; return FALSE;
if (ppStoreContext) if (ppStoreContext) {
*ppStoreContext = CertDuplicateCRLContext(context); Context_AddRef(context);
*ppStoreContext = context_ptr(context);
}
return TRUE; return TRUE;
} }
@ -230,16 +234,18 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
void *toReplace, const void **ppStoreContext, BOOL use_link) void *toReplace, const void **ppStoreContext, BOOL use_link)
{ {
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store; WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
PCTL_CONTEXT context; context_t *context;
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, 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) if (!context)
return FALSE; return FALSE;
if (ppStoreContext) if (ppStoreContext) {
*ppStoreContext = CertDuplicateCTLContext(context); Context_AddRef(context);
*ppStoreContext = context_ptr(context);
}
return TRUE; return TRUE;
} }