Jacek Caban : crypt32: Share more code between memory store enumContext implementations.

Alexandre Julliard julliard at winehq.org
Thu Oct 17 13:51:50 CDT 2013


Module: wine
Branch: master
Commit: 4d28e14acb270ad7266ce720c4a8473ccb6ebe6d
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4d28e14acb270ad7266ce720c4a8473ccb6ebe6d

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Oct 17 11:09:50 2013 +0200

crypt32: Share more code between memory store enumContext implementations.

---

 dlls/crypt32/context.c         |   25 --------------------
 dlls/crypt32/crypt32_private.h |    2 -
 dlls/crypt32/store.c           |   49 ++++++++++++++++++++++-----------------
 3 files changed, 28 insertions(+), 48 deletions(-)

diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c
index 60c82ec..6a96943 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 0dd76fc..3a6d9d5 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 660219d..bf9c88e 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)




More information about the wine-cvs mailing list