Jacek Caban : crypt32: Share more code between memory store addContext implementations.
Alexandre Julliard
julliard at winehq.org
Thu Oct 17 13:51:50 CDT 2013
Module: wine
Branch: master
Commit: 63eed79d25ba63fdbc0aca45e2055ceb40e661f0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=63eed79d25ba63fdbc0aca45e2055ceb40e661f0
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Oct 17 11:09:37 2013 +0200
crypt32: Share more code between memory store addContext implementations.
---
dlls/crypt32/context.c | 28 ------------------
dlls/crypt32/crypt32_private.h | 3 --
dlls/crypt32/store.c | 60 +++++++++++++++++++++------------------
3 files changed, 32 insertions(+), 59 deletions(-)
diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c
index d6d67d1..60c82ec 100644
--- a/dlls/crypt32/context.c
+++ b/dlls/crypt32/context.c
@@ -110,34 +110,6 @@ void Context_CopyProperties(const void *to, const void *from)
ContextPropertyList_Copy(toProperties, fromProperties);
}
-context_t *ContextList_Add(ContextList *list, CRITICAL_SECTION *cs, context_t *toLink,
- context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link)
-{
- context_t *context;
-
- TRACE("(%p, %p, %p)\n", list, toLink, existing);
-
- context = toLink->vtbl->clone(toLink, store, use_link);
- if (context)
- {
- TRACE("adding %p\n", context);
- EnterCriticalSection(cs);
- if (existing)
- {
- 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(existing);
- }
- else
- list_add_head(list, &context->u.entry);
- LeaveCriticalSection(cs);
- }
- return context;
-}
-
context_t *ContextList_Enum(ContextList *list, CRITICAL_SECTION *cs, context_t *prev)
{
struct list *listNext;
diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
index a0f96c5..0dd76fc 100644
--- a/dlls/crypt32/crypt32_private.h
+++ b/dlls/crypt32/crypt32_private.h
@@ -438,9 +438,6 @@ void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
*/
typedef struct list ContextList;
-context_t *ContextList_Add(ContextList *list, CRITICAL_SECTION *cs, context_t *toLink, context_t *toReplace,
- struct WINE_CRYPTCERTSTORE *store, BOOL use_link) 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,
diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c
index 8222d24..660219d 100644
--- a/dlls/crypt32/store.c
+++ b/dlls/crypt32/store.c
@@ -143,25 +143,47 @@ BOOL WINAPI I_CertUpdateStore(HCERTSTORE store1, HCERTSTORE store2, DWORD unk0,
return TRUE;
}
-static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
- context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
+static BOOL MemStore_addContext(WINE_MEMSTORE *store, struct list *list, context_t *orig_context,
+ context_t *existing, context_t **ret_context, BOOL use_link)
{
- WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *context;
- TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
-
- context = ContextList_Add(&ms->certs, &ms->cs, cert, toReplace, store, use_link);
+ context = orig_context->vtbl->clone(orig_context, &store->hdr, use_link);
if (!context)
return FALSE;
- if (ppStoreContext) {
+ TRACE("adding %p\n", context);
+ EnterCriticalSection(&store->cs);
+ if (existing) {
+ 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(existing);
+ }else {
+ list_add_head(list, &context->u.entry);
+ }
+ LeaveCriticalSection(&store->cs);
+
+ if(ret_context) {
Context_AddRef(context);
- *ppStoreContext = context;
+ *ret_context = context;
}
+
return TRUE;
}
+static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
+ context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
+{
+ WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
+
+ TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
+
+ return MemStore_addContext(ms, &ms->certs, cert, toReplace, ppStoreContext, use_link);
+}
+
static context_t *MemStore_enumCert(WINECRYPT_CERTSTORE *store, context_t *prev)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
@@ -191,19 +213,10 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
- context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
- context = ContextList_Add(&ms->crls, &ms->cs, crl, toReplace, store, use_link);
- if (!context)
- return FALSE;
-
- if (ppStoreContext) {
- Context_AddRef(context);
- *ppStoreContext = context;
- }
- return TRUE;
+ return MemStore_addContext(ms, &ms->crls, crl, toReplace, ppStoreContext, use_link);
}
static context_t *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, context_t *prev)
@@ -235,19 +248,10 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
- context_t *context;
TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
- context = ContextList_Add(&ms->ctls, &ms->cs, ctl, toReplace, store, use_link);
- if (!context)
- return FALSE;
-
- if (ppStoreContext) {
- Context_AddRef(context);
- *ppStoreContext = context;
- }
- return TRUE;
+ return MemStore_addContext(ms, &ms->ctls, ctl, toReplace, ppStoreContext, use_link);
}
static context_t *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, context_t *prev)
More information about the wine-cvs
mailing list