diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c index 60c82ec46a2..6a969436810 100644 --- a/dlls/crypt32/context.c +++ b/dlls/crypt32/context.c @@ -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; diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h index 0dd76fcdcc3..3a6d9d550db 100644 --- a/dlls/crypt32/crypt32_private.h +++ b/dlls/crypt32/crypt32_private.h @@ -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.) diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c index 660219d47c4..bf9c88e4fb4 100644 --- a/dlls/crypt32/store.c +++ b/dlls/crypt32/store.c @@ -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)