Jacek Caban : crypt32: Share more code between memory store deleteContext implementations.
Alexandre Julliard
julliard at winehq.org
Thu Oct 17 13:51:50 CDT 2013
Module: wine
Branch: master
Commit: bf464f81a8e71ddc6659b8776c4d4827896606f9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bf464f81a8e71ddc6659b8776c4d4827896606f9
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Oct 17 11:10:05 2013 +0200
crypt32: Share more code between memory store deleteContext implementations.
---
dlls/crypt32/context.c | 16 ----------------
dlls/crypt32/crypt32_private.h | 6 ------
dlls/crypt32/store.c | 32 ++++++++++++++++++++++----------
3 files changed, 22 insertions(+), 32 deletions(-)
diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c
index 6a96943..82b1021 100644
--- a/dlls/crypt32/context.c
+++ b/dlls/crypt32/context.c
@@ -110,22 +110,6 @@ void Context_CopyProperties(const void *to, const void *from)
ContextPropertyList_Copy(toProperties, fromProperties);
}
-BOOL ContextList_Remove(ContextList *list, CRITICAL_SECTION *cs, context_t *context)
-{
- BOOL inList = FALSE;
-
- EnterCriticalSection(cs);
- if (!list_empty(&context->u.entry))
- {
- list_remove(&context->u.entry);
- list_init(&context->u.entry);
- inList = TRUE;
- }
- LeaveCriticalSection(cs);
-
- return inList;
-}
-
void ContextList_Free(ContextList *list)
{
context_t *context, *next;
diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
index 3a6d9d5..dc66ebf 100644
--- a/dlls/crypt32/crypt32_private.h
+++ b/dlls/crypt32/crypt32_private.h
@@ -438,12 +438,6 @@ void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
*/
typedef struct list ContextList;
-/* 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
- * removes have no effect.)
- */
-BOOL ContextList_Remove(ContextList *list, CRITICAL_SECTION *cs, context_t *context) DECLSPEC_HIDDEN;
-
void ContextList_Free(ContextList *list) DECLSPEC_HIDDEN;
extern WINECRYPT_CERTSTORE empty_store;
diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c
index bf9c88e..76ba944 100644
--- a/dlls/crypt32/store.c
+++ b/dlls/crypt32/store.c
@@ -198,6 +198,22 @@ static context_t *MemStore_enumContext(WINE_MEMSTORE *store, struct list *list,
return ret;
}
+static BOOL MemStore_deleteContext(WINE_MEMSTORE *store, context_t *context)
+{
+ BOOL in_list = FALSE;
+
+ EnterCriticalSection(&store->cs);
+ if (!list_empty(&context->u.entry)) {
+ list_remove(&context->u.entry);
+ list_init(&context->u.entry);
+ in_list = TRUE;
+ }
+ LeaveCriticalSection(&store->cs);
+
+ if(in_list)
+ Context_Release(context);
+ return TRUE;
+}
static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
@@ -205,7 +221,6 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
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);
}
@@ -222,10 +237,9 @@ static BOOL MemStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
- if (ContextList_Remove(&ms->certs, &ms->cs, context))
- Context_Release(context);
+ TRACE("(%p, %p)\n", store, context);
- return TRUE;
+ return MemStore_deleteContext(ms, context);
}
static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
@@ -251,10 +265,9 @@ static BOOL MemStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *context)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
- if (!ContextList_Remove(&ms->crls, &ms->cs, context))
- Context_Release(context);
+ TRACE("(%p, %p)\n", store, context);
- return TRUE;
+ return MemStore_deleteContext(ms, context);
}
static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
@@ -280,10 +293,9 @@ static BOOL MemStore_deleteCTL(WINECRYPT_CERTSTORE *store, context_t *context)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
- if (!ContextList_Remove(&ms->ctls, &ms->cs, context))
- Context_Release(context);
+ TRACE("(%p, %p)\n", store, context);
- return TRUE;
+ return MemStore_deleteContext(ms, context);
}
static void MemStore_addref(WINECRYPT_CERTSTORE *store)
More information about the wine-cvs
mailing list