crypt32: Share more code between memory store enumContext implementations.

This commit is contained in:
Jacek Caban 2013-10-17 11:09:50 +02:00 committed by Alexandre Julliard
parent 63eed79d25
commit 4d28e14acb
3 changed files with 28 additions and 48 deletions

View File

@ -110,31 +110,6 @@ void Context_CopyProperties(const void *to, const void *from)
ContextPropertyList_Copy(toProperties, fromProperties);
}
context_t *ContextList_Enum(ContextList *list, CRITICAL_SECTION *cs, context_t *prev)
{
struct list *listNext;
context_t *ret;
EnterCriticalSection(cs);
if (prev)
{
listNext = list_next(list, &prev->u.entry);
Context_Release(prev);
}
else
listNext = list_next(list, list);
LeaveCriticalSection(cs);
if (listNext)
{
ret = LIST_ENTRY(listNext, context_t, u.entry);
Context_AddRef(ret);
}
else
ret = NULL;
return ret;
}
BOOL ContextList_Remove(ContextList *list, CRITICAL_SECTION *cs, context_t *context)
{
BOOL inList = FALSE;

View File

@ -438,8 +438,6 @@ void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
*/
typedef struct list ContextList;
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,
* or FALSE if not. (The context may have been duplicated, so subsequent
* removes have no effect.)

View File

@ -174,6 +174,31 @@ static BOOL MemStore_addContext(WINE_MEMSTORE *store, struct list *list, context
return TRUE;
}
static context_t *MemStore_enumContext(WINE_MEMSTORE *store, struct list *list, context_t *prev)
{
struct list *next;
context_t *ret;
EnterCriticalSection(&store->cs);
if (prev) {
next = list_next(list, &prev->u.entry);
Context_Release(prev);
}else {
next = list_next(list, list);
}
LeaveCriticalSection(&store->cs);
if (!next) {
SetLastError(CRYPT_E_NOT_FOUND);
return NULL;
}
ret = LIST_ENTRY(next, context_t, u.entry);
Context_AddRef(ret);
return ret;
}
static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
context_t *toReplace, context_t **ppStoreContext, BOOL use_link)
{
@ -187,16 +212,10 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
static context_t *MemStore_enumCert(WINECRYPT_CERTSTORE *store, context_t *prev)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *ret;
TRACE("(%p, %p)\n", store, prev);
ret = ContextList_Enum(&ms->certs, &ms->cs, prev);
if (!ret)
SetLastError(CRYPT_E_NOT_FOUND);
TRACE("returning %p\n", ret);
return ret;
return MemStore_enumContext(ms, &ms->certs, prev);
}
static BOOL MemStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context)
@ -222,16 +241,10 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
static context_t *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, context_t *prev)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *ret;
TRACE("(%p, %p)\n", store, prev);
ret = ContextList_Enum(&ms->crls, &ms->cs, prev);
if (!ret)
SetLastError(CRYPT_E_NOT_FOUND);
TRACE("returning %p\n", ret);
return ret;
return MemStore_enumContext(ms, &ms->crls, prev);
}
static BOOL MemStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *context)
@ -257,16 +270,10 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
static context_t *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, context_t *prev)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
context_t *ret;
TRACE("(%p, %p)\n", store, prev);
ret = ContextList_Enum(&ms->ctls, &ms->cs, prev);
if (!ret)
SetLastError(CRYPT_E_NOT_FOUND);
TRACE("returning %p\n", ret);
return ret;
return MemStore_enumContext(ms, &ms->ctls, prev);
}
static BOOL MemStore_deleteCTL(WINECRYPT_CERTSTORE *store, context_t *context)