crypt32(6/11): Where possible, pass a pointer rather than an offset, it's less confusing

Juan Lang juan.lang at gmail.com
Thu Aug 16 13:02:57 CDT 2007


--Juan
-------------- next part --------------
From 6f3c65da497c9efbfed16371c65aa71562082e57 Mon Sep 17 00:00:00 2001
From: Juan Lang <juan.lang at gmail.com>
Date: Thu, 16 Aug 2007 10:45:02 -0700
Subject: [PATCH] Where possible, pass a pointer rather than an offset, it's less confusing
---
 dlls/crypt32/store.c |   29 ++++++++++++++++++-----------
 1 files changed, 18 insertions(+), 11 deletions(-)

diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c
index aaecf11..df2053f 100644
--- a/dlls/crypt32/store.c
+++ b/dlls/crypt32/store.c
@@ -477,13 +477,11 @@ static BOOL CRYPT_CollectionAddContext(P
  * Assumes the collection store's lock is held.
  */
 static void *CRYPT_CollectionAdvanceEnum(PWINE_COLLECTIONSTORE store,
- PWINE_STORE_LIST_ENTRY storeEntry, size_t contextFuncsOffset,
+ PWINE_STORE_LIST_ENTRY storeEntry, PCONTEXT_FUNCS contextFuncs,
  PCWINE_CONTEXT_INTERFACE contextInterface, void *pPrev, size_t contextSize)
 {
     void *ret, *child;
     struct list *storeNext = list_next(&store->stores, &storeEntry->entry);
-    PCONTEXT_FUNCS contextFuncs = (PCONTEXT_FUNCS)((LPBYTE)storeEntry->store +
-     contextFuncsOffset);
 
     TRACE("(%p, %p, %p)\n", store, storeEntry, pPrev);
 
@@ -506,9 +504,19 @@ static void *CRYPT_CollectionAdvanceEnum
     else
     {
         if (storeNext)
-            ret = CRYPT_CollectionAdvanceEnum(store, LIST_ENTRY(storeNext,
-             WINE_STORE_LIST_ENTRY, entry), contextFuncsOffset,
-             contextInterface, NULL, contextSize);
+        {
+            /* We always want the same function pointers (from certs, crls)
+             * in the next store, so use the same offset into the next store.
+             */
+            size_t offset = (LPBYTE)contextFuncs - (LPBYTE)storeEntry->store;
+            PWINE_STORE_LIST_ENTRY storeNextEntry =
+             LIST_ENTRY(storeNext, WINE_STORE_LIST_ENTRY, entry);
+            PCONTEXT_FUNCS storeNextContexts =
+             (PCONTEXT_FUNCS)((LPBYTE)storeNextEntry->store + offset);
+
+            ret = CRYPT_CollectionAdvanceEnum(store, storeNextEntry,
+             storeNextContexts, contextInterface, NULL, contextSize);
+        }
         else
         {
             SetLastError(CRYPT_E_NOT_FOUND);
@@ -559,7 +567,7 @@ static void *CRYPT_CollectionEnumCert(PW
          sizeof(CERT_CONTEXT));
 
         ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
-         offsetof(WINECRYPT_CERTSTORE, certs), pCertInterface, pPrev,
+         &storeEntry->store->certs, pCertInterface, pPrev,
          sizeof(CERT_CONTEXT));
     }
     else
@@ -570,7 +578,7 @@ static void *CRYPT_CollectionEnumCert(PW
              WINE_STORE_LIST_ENTRY, entry);
 
             ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
-             offsetof(WINECRYPT_CERTSTORE, certs), pCertInterface, NULL,
+             &storeEntry->store->certs, pCertInterface, NULL,
              sizeof(CERT_CONTEXT));
         }
         else
@@ -638,8 +646,7 @@ static void *CRYPT_CollectionEnumCRL(PWI
          sizeof(CRL_CONTEXT));
 
         ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
-         offsetof(WINECRYPT_CERTSTORE, crls), pCRLInterface, pPrev,
-         sizeof(CRL_CONTEXT));
+         &storeEntry->store->crls, pCRLInterface, pPrev, sizeof(CRL_CONTEXT));
     }
     else
     {
@@ -649,7 +656,7 @@ static void *CRYPT_CollectionEnumCRL(PWI
              WINE_STORE_LIST_ENTRY, entry);
 
             ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
-             offsetof(WINECRYPT_CERTSTORE, crls), pCRLInterface, NULL,
+             &storeEntry->store->crls, pCRLInterface, NULL,
              sizeof(CRL_CONTEXT));
         }
         else
-- 
1.4.1


More information about the wine-patches mailing list