crypt32: Share more code between memory store deleteContext implementations.
This commit is contained in:
parent
4d28e14acb
commit
bf464f81a8
@ -110,22 +110,6 @@ void Context_CopyProperties(const void *to, const void *from)
|
|||||||
ContextPropertyList_Copy(toProperties, fromProperties);
|
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)
|
void ContextList_Free(ContextList *list)
|
||||||
{
|
{
|
||||||
context_t *context, *next;
|
context_t *context, *next;
|
||||||
|
@ -438,12 +438,6 @@ void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
|
|||||||
*/
|
*/
|
||||||
typedef struct list ContextList;
|
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;
|
void ContextList_Free(ContextList *list) DECLSPEC_HIDDEN;
|
||||||
|
|
||||||
extern WINECRYPT_CERTSTORE empty_store;
|
extern WINECRYPT_CERTSTORE empty_store;
|
||||||
|
@ -198,6 +198,22 @@ static context_t *MemStore_enumContext(WINE_MEMSTORE *store, struct list *list,
|
|||||||
return ret;
|
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,
|
static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
|
||||||
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
|
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;
|
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
||||||
|
|
||||||
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
|
TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
|
||||||
|
|
||||||
return MemStore_addContext(ms, &ms->certs, cert, toReplace, ppStoreContext, use_link);
|
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;
|
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
||||||
|
|
||||||
if (ContextList_Remove(&ms->certs, &ms->cs, context))
|
TRACE("(%p, %p)\n", store, context);
|
||||||
Context_Release(context);
|
|
||||||
|
|
||||||
return TRUE;
|
return MemStore_deleteContext(ms, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
|
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;
|
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
||||||
|
|
||||||
if (!ContextList_Remove(&ms->crls, &ms->cs, context))
|
TRACE("(%p, %p)\n", store, context);
|
||||||
Context_Release(context);
|
|
||||||
|
|
||||||
return TRUE;
|
return MemStore_deleteContext(ms, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
|
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;
|
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
|
||||||
|
|
||||||
if (!ContextList_Remove(&ms->ctls, &ms->cs, context))
|
TRACE("(%p, %p)\n", store, context);
|
||||||
Context_Release(context);
|
|
||||||
|
|
||||||
return TRUE;
|
return MemStore_deleteContext(ms, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void MemStore_addref(WINECRYPT_CERTSTORE *store)
|
static void MemStore_addref(WINECRYPT_CERTSTORE *store)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user