Jacek Caban : crypt32: Use list struct directly instead of ContextList wrapper.

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


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

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

crypt32: Use list struct directly instead of ContextList wrapper.

---

 dlls/crypt32/context.c         |   38 ++++++++------------------------------
 dlls/crypt32/crypt32_private.h |   12 +++++-------
 dlls/crypt32/store.c           |   36 ++++++++++++++++++------------------
 3 files changed, 31 insertions(+), 55 deletions(-)

diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c
index 25cb8be..d6d67d1 100644
--- a/dlls/crypt32/context.c
+++ b/dlls/crypt32/context.c
@@ -110,23 +110,7 @@ void Context_CopyProperties(const void *to, const void *from)
     ContextPropertyList_Copy(toProperties, fromProperties);
 }
 
-struct ContextList
-{
-    struct list contexts;
-};
-
-struct ContextList *ContextList_Create(void)
-{
-    struct ContextList *list = CryptMemAlloc(sizeof(struct ContextList));
-
-    if (list)
-    {
-        list_init(&list->contexts);
-    }
-    return list;
-}
-
-context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, context_t *toLink,
+context_t *ContextList_Add(ContextList *list, CRITICAL_SECTION *cs, context_t *toLink,
  context_t *existing, struct WINE_CRYPTCERTSTORE *store, BOOL use_link)
 {
     context_t *context;
@@ -148,13 +132,13 @@ context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, conte
             Context_Release(existing);
         }
         else
-            list_add_head(&list->contexts, &context->u.entry);
+            list_add_head(list, &context->u.entry);
         LeaveCriticalSection(cs);
     }
     return context;
 }
 
-context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, context_t *prev)
+context_t *ContextList_Enum(ContextList *list, CRITICAL_SECTION *cs, context_t *prev)
 {
     struct list *listNext;
     context_t *ret;
@@ -162,11 +146,11 @@ context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, cont
     EnterCriticalSection(cs);
     if (prev)
     {
-        listNext = list_next(&list->contexts, &prev->u.entry);
+        listNext = list_next(list, &prev->u.entry);
         Context_Release(prev);
     }
     else
-        listNext = list_next(&list->contexts, &list->contexts);
+        listNext = list_next(list, list);
     LeaveCriticalSection(cs);
 
     if (listNext)
@@ -179,7 +163,7 @@ context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, cont
     return ret;
 }
 
-BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_t *context)
+BOOL ContextList_Remove(ContextList *list, CRITICAL_SECTION *cs, context_t *context)
 {
     BOOL inList = FALSE;
 
@@ -195,20 +179,14 @@ BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_
     return inList;
 }
 
-static void ContextList_Empty(struct ContextList *list)
+void ContextList_Free(ContextList *list)
 {
     context_t *context, *next;
 
-    LIST_FOR_EACH_ENTRY_SAFE(context, next, &list->contexts, context_t, u.entry)
+    LIST_FOR_EACH_ENTRY_SAFE(context, next, list, context_t, u.entry)
     {
         TRACE("removing %p\n", context);
         list_remove(&context->u.entry);
         Context_Release(context);
     }
 }
-
-void ContextList_Free(struct ContextList *list)
-{
-    ContextList_Empty(list);
-    CryptMemFree(list);
-}
diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
index 2061ee4..a0f96c5 100644
--- a/dlls/crypt32/crypt32_private.h
+++ b/dlls/crypt32/crypt32_private.h
@@ -436,22 +436,20 @@ void ContextPropertyList_Free(CONTEXT_PROPERTY_LIST *list) DECLSPEC_HIDDEN;
 /**
  *  Context list functions.  A context list is a simple list of link contexts.
  */
-struct ContextList;
+typedef struct list ContextList;
 
-struct ContextList *ContextList_Create(void) DECLSPEC_HIDDEN;
-
-context_t *ContextList_Add(struct ContextList *list, CRITICAL_SECTION *cs, context_t *toLink, context_t *toReplace,
+context_t *ContextList_Add(ContextList *list, CRITICAL_SECTION *cs, context_t *toLink, context_t *toReplace,
  struct WINE_CRYPTCERTSTORE *store, BOOL use_link) DECLSPEC_HIDDEN;
 
-context_t *ContextList_Enum(struct ContextList *list, CRITICAL_SECTION *cs, context_t *prev) DECLSPEC_HIDDEN;
+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.)
  */
-BOOL ContextList_Remove(struct ContextList *list, CRITICAL_SECTION *cs, context_t *context) DECLSPEC_HIDDEN;
+BOOL ContextList_Remove(ContextList *list, CRITICAL_SECTION *cs, context_t *context) DECLSPEC_HIDDEN;
 
-void ContextList_Free(struct ContextList *list) DECLSPEC_HIDDEN;
+void ContextList_Free(ContextList *list) DECLSPEC_HIDDEN;
 
 extern WINECRYPT_CERTSTORE empty_store;
 void init_empty_store(void) DECLSPEC_HIDDEN;
diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c
index 3cbf9e4..8222d24 100644
--- a/dlls/crypt32/store.c
+++ b/dlls/crypt32/store.c
@@ -83,9 +83,9 @@ typedef struct _WINE_MEMSTORE
 {
     WINECRYPT_CERTSTORE hdr;
     CRITICAL_SECTION cs;
-    struct ContextList *certs;
-    struct ContextList *crls;
-    struct ContextList *ctls;
+    struct list certs;
+    struct list crls;
+    struct list ctls;
 } WINE_MEMSTORE;
 
 void CRYPT_InitStore(WINECRYPT_CERTSTORE *store, DWORD dwFlags, CertStoreType type, const store_vtbl_t *vtbl)
@@ -151,7 +151,7 @@ static BOOL MemStore_addCert(WINECRYPT_CERTSTORE *store, context_t *cert,
 
     TRACE("(%p, %p, %p, %p)\n", store, cert, toReplace, ppStoreContext);
 
-    context = ContextList_Add(ms->certs, &ms->cs, cert, toReplace, store, use_link);
+    context = ContextList_Add(&ms->certs, &ms->cs, cert, toReplace, store, use_link);
     if (!context)
         return FALSE;
 
@@ -169,7 +169,7 @@ static context_t *MemStore_enumCert(WINECRYPT_CERTSTORE *store, context_t *prev)
 
     TRACE("(%p, %p)\n", store, prev);
 
-    ret = ContextList_Enum(ms->certs, &ms->cs, prev);
+    ret = ContextList_Enum(&ms->certs, &ms->cs, prev);
     if (!ret)
         SetLastError(CRYPT_E_NOT_FOUND);
 
@@ -181,7 +181,7 @@ static BOOL MemStore_deleteCert(WINECRYPT_CERTSTORE *store, context_t *context)
 {
     WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
 
-    if (ContextList_Remove(ms->certs, &ms->cs, context))
+    if (ContextList_Remove(&ms->certs, &ms->cs, context))
         Context_Release(context);
 
     return TRUE;
@@ -195,7 +195,7 @@ static BOOL MemStore_addCRL(WINECRYPT_CERTSTORE *store, context_t *crl,
 
     TRACE("(%p, %p, %p, %p)\n", store, crl, toReplace, ppStoreContext);
 
-    context = ContextList_Add(ms->crls, &ms->cs, crl, toReplace, store, use_link);
+    context = ContextList_Add(&ms->crls, &ms->cs, crl, toReplace, store, use_link);
     if (!context)
         return FALSE;
 
@@ -213,7 +213,7 @@ static context_t *MemStore_enumCRL(WINECRYPT_CERTSTORE *store, context_t *prev)
 
     TRACE("(%p, %p)\n", store, prev);
 
-    ret = ContextList_Enum(ms->crls, &ms->cs, prev);
+    ret = ContextList_Enum(&ms->crls, &ms->cs, prev);
     if (!ret)
         SetLastError(CRYPT_E_NOT_FOUND);
 
@@ -225,7 +225,7 @@ static BOOL MemStore_deleteCRL(WINECRYPT_CERTSTORE *store, context_t *context)
 {
     WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
 
-    if (!ContextList_Remove(ms->crls, &ms->cs, context))
+    if (!ContextList_Remove(&ms->crls, &ms->cs, context))
         Context_Release(context);
 
     return TRUE;
@@ -239,7 +239,7 @@ static BOOL MemStore_addCTL(WINECRYPT_CERTSTORE *store, context_t *ctl,
 
     TRACE("(%p, %p, %p, %p)\n", store, ctl, toReplace, ppStoreContext);
 
-    context = ContextList_Add(ms->ctls, &ms->cs, ctl, toReplace, store, use_link);
+    context = ContextList_Add(&ms->ctls, &ms->cs, ctl, toReplace, store, use_link);
     if (!context)
         return FALSE;
 
@@ -257,7 +257,7 @@ static context_t *MemStore_enumCTL(WINECRYPT_CERTSTORE *store, context_t *prev)
 
     TRACE("(%p, %p)\n", store, prev);
 
-    ret = ContextList_Enum(ms->ctls, &ms->cs, prev);
+    ret = ContextList_Enum(&ms->ctls, &ms->cs, prev);
     if (!ret)
         SetLastError(CRYPT_E_NOT_FOUND);
 
@@ -269,7 +269,7 @@ static BOOL MemStore_deleteCTL(WINECRYPT_CERTSTORE *store, context_t *context)
 {
     WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
 
-    if (!ContextList_Remove(ms->ctls, &ms->cs, context))
+    if (!ContextList_Remove(&ms->ctls, &ms->cs, context))
         Context_Release(context);
 
     return TRUE;
@@ -294,9 +294,9 @@ static DWORD MemStore_release(WINECRYPT_CERTSTORE *cert_store, DWORD flags)
     if(ref)
         return (flags & CERT_CLOSE_STORE_CHECK_FLAG) ? CRYPT_E_PENDING_CLOSE : ERROR_SUCCESS;
 
-    ContextList_Free(store->certs);
-    ContextList_Free(store->crls);
-    ContextList_Free(store->ctls);
+    ContextList_Free(&store->certs);
+    ContextList_Free(&store->crls);
+    ContextList_Free(&store->ctls);
     store->cs.DebugInfo->Spare[0] = 0;
     DeleteCriticalSection(&store->cs);
     CRYPT_FreeStore(&store->hdr);
@@ -350,9 +350,9 @@ static WINECRYPT_CERTSTORE *CRYPT_MemOpenStore(HCRYPTPROV hCryptProv,
             CRYPT_InitStore(&store->hdr, dwFlags, StoreTypeMem, &MemStoreVtbl);
             InitializeCriticalSection(&store->cs);
             store->cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": ContextList.cs");
-            store->certs = ContextList_Create();
-            store->crls = ContextList_Create();
-            store->ctls = ContextList_Create();
+            list_init(&store->certs);
+            list_init(&store->crls);
+            list_init(&store->ctls);
             /* Mem store doesn't need crypto provider, so close it */
             if (hCryptProv && !(dwFlags & CERT_STORE_NO_CRYPT_RELEASE_FLAG))
                 CryptReleaseContext(hCryptProv, 0);




More information about the wine-cvs mailing list