crypt32: Share more code between memory store deleteContext implementations.

This commit is contained in:
Jacek Caban 2013-10-17 11:10:05 +02:00 committed by Alexandre Julliard
parent 4d28e14acb
commit bf464f81a8
3 changed files with 22 additions and 32 deletions

View File

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

View File

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

View File

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