Jacek Caban : crypt32: Store extra pointer directly in context_t and get rid of Context_GetExtra.
Alexandre Julliard
julliard at winehq.org
Tue Oct 15 13:27:13 CDT 2013
Module: wine
Branch: master
Commit: 03ff35c270f8c7786574208d5954825b2a3d76c1
URL: http://source.winehq.org/git/wine.git/?a=commit;h=03ff35c270f8c7786574208d5954825b2a3d76c1
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Oct 15 16:53:26 2013 +0200
crypt32: Store extra pointer directly in context_t and get rid of Context_GetExtra.
---
dlls/crypt32/collectionstore.c | 42 ++++++++++++++++-----------------------
dlls/crypt32/context.c | 8 +++---
dlls/crypt32/crypt32_private.h | 10 ++------
3 files changed, 24 insertions(+), 36 deletions(-)
diff --git a/dlls/crypt32/collectionstore.c b/dlls/crypt32/collectionstore.c
index 284519f..7be5afb 100644
--- a/dlls/crypt32/collectionstore.c
+++ b/dlls/crypt32/collectionstore.c
@@ -72,14 +72,15 @@ static DWORD Collection_release(WINECRYPT_CERTSTORE *store, DWORD flags)
}
static void *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *store,
- WINE_STORE_LIST_ENTRY *storeEntry, void *child, size_t contextSize)
+ WINE_STORE_LIST_ENTRY *storeEntry, context_t *child, size_t contextSize)
{
- context_t *ret = Context_CreateLinkContext(contextSize, context_from_ptr(child),
- sizeof(WINE_STORE_LIST_ENTRY*));
+ context_t *ret;
- if (ret)
- *(WINE_STORE_LIST_ENTRY **)Context_GetExtra(context_ptr(ret), contextSize) = storeEntry;
+ ret = Context_CreateLinkContext(contextSize, child);
+ if (!ret)
+ return NULL;
+ ret->u.ptr = storeEntry;
return context_ptr(ret);
}
@@ -100,8 +101,7 @@ static BOOL CRYPT_CollectionAddContext(WINE_COLLECTIONSTORE *store,
void *existingLinked = Context_GetLinkedContext(toReplace);
CONTEXT_FUNCS *contextFuncs;
- storeEntry = *(WINE_STORE_LIST_ENTRY **)Context_GetExtra(toReplace,
- contextSize);
+ storeEntry = context_from_ptr(toReplace)->u.ptr;
contextFuncs = (CONTEXT_FUNCS*)((LPBYTE)storeEntry->store->vtbl +
contextFuncsOffset);
ret = contextFuncs->addContext(storeEntry->store, context,
@@ -166,7 +166,7 @@ static void *CRYPT_CollectionAdvanceEnum(WINE_COLLECTIONSTORE *store,
else
child = contextFuncs->enumContext(storeEntry->store, NULL);
if (child) {
- ret = CRYPT_CollectionCreateContextFromChild(store, storeEntry, child, contextSize);
+ ret = CRYPT_CollectionCreateContextFromChild(store, storeEntry, context_from_ptr(child), contextSize);
Context_Release(context_from_ptr(child));
}
else
@@ -206,10 +206,9 @@ static BOOL Collection_addCert(WINECRYPT_CERTSTORE *store, void *cert,
cert, toReplace, sizeof(CERT_CONTEXT), &childContext);
if (ppStoreContext && childContext)
{
- WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **)
- Context_GetExtra(childContext, sizeof(CERT_CONTEXT));
+ WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
PCERT_CONTEXT context =
- CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CERT_CONTEXT));
+ CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CERT_CONTEXT));
if (context)
context->hCertStore = store;
@@ -229,9 +228,7 @@ static void *Collection_enumCert(WINECRYPT_CERTSTORE *store, void *pPrev)
EnterCriticalSection(&cs->cs);
if (pPrev)
{
- WINE_STORE_LIST_ENTRY *storeEntry =
- *(WINE_STORE_LIST_ENTRY **)Context_GetExtra(pPrev,
- sizeof(CERT_CONTEXT));
+ WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(pPrev)->u.ptr;
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
&storeEntry->store->vtbl->certs, pCertInterface, pPrev,
@@ -285,10 +282,9 @@ static BOOL Collection_addCRL(WINECRYPT_CERTSTORE *store, void *crl,
crl, toReplace, sizeof(CRL_CONTEXT), &childContext);
if (ppStoreContext && childContext)
{
- WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **)
- Context_GetExtra(childContext, sizeof(CRL_CONTEXT));
+ WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
PCRL_CONTEXT context =
- CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CRL_CONTEXT));
+ CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CRL_CONTEXT));
if (context)
context->hCertStore = store;
@@ -308,9 +304,7 @@ static void *Collection_enumCRL(WINECRYPT_CERTSTORE *store, void *pPrev)
EnterCriticalSection(&cs->cs);
if (pPrev)
{
- WINE_STORE_LIST_ENTRY *storeEntry =
- *(WINE_STORE_LIST_ENTRY **)Context_GetExtra(pPrev,
- sizeof(CRL_CONTEXT));
+ WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(pPrev)->u.ptr;
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
&storeEntry->store->vtbl->crls, pCRLInterface, pPrev, sizeof(CRL_CONTEXT));
@@ -363,10 +357,9 @@ static BOOL Collection_addCTL(WINECRYPT_CERTSTORE *store, void *ctl,
ctl, toReplace, sizeof(CTL_CONTEXT), &childContext);
if (ppStoreContext && childContext)
{
- WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **)
- Context_GetExtra(childContext, sizeof(CTL_CONTEXT));
+ WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
PCTL_CONTEXT context =
- CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CTL_CONTEXT));
+ CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CTL_CONTEXT));
if (context)
context->hCertStore = store;
@@ -386,8 +379,7 @@ static void *Collection_enumCTL(WINECRYPT_CERTSTORE *store, void *pPrev)
EnterCriticalSection(&cs->cs);
if (pPrev)
{
- WINE_STORE_LIST_ENTRY *storeEntry =
- *(WINE_STORE_LIST_ENTRY **)Context_GetExtra(pPrev, sizeof(CTL_CONTEXT));
+ WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(pPrev)->u.ptr;
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
&storeEntry->store->vtbl->ctls, pCTLInterface, pPrev, sizeof(CTL_CONTEXT));
diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c
index 527eb79..6809b4b 100644
--- a/dlls/crypt32/context.c
+++ b/dlls/crypt32/context.c
@@ -50,13 +50,13 @@ void *Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl)
return CONTEXT_FROM_BASE_CONTEXT(context);
}
-context_t *Context_CreateLinkContext(unsigned int contextSize, context_t *linked, unsigned int extra)
+context_t *Context_CreateLinkContext(unsigned int contextSize, context_t *linked)
{
context_t *context;
- TRACE("(%d, %p, %d)\n", contextSize, linked, extra);
+ TRACE("(%d, %p)\n", contextSize, linked);
- context = CryptMemAlloc(contextSize + sizeof(BASE_CONTEXT) + extra);
+ context = CryptMemAlloc(sizeof(context_t) + contextSize);
if (!context)
return NULL;
@@ -168,7 +168,7 @@ void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace)
TRACE("(%p, %p, %p)\n", list, toLink, toReplace);
- context = Context_CreateLinkContext(list->contextSize, context_from_ptr(toLink), 0);
+ context = Context_CreateLinkContext(list->contextSize, context_from_ptr(toLink));
if (context)
{
TRACE("adding %p\n", context);
diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
index 20ba276..de1383c 100644
--- a/dlls/crypt32/crypt32_private.h
+++ b/dlls/crypt32/crypt32_private.h
@@ -174,6 +174,7 @@ typedef struct _context_t {
CONTEXT_PROPERTY_LIST *properties;
union {
struct list entry;
+ void *ptr;
} u;
} BASE_CONTEXT;
@@ -395,17 +396,12 @@ DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent,
*/
void *Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl) DECLSPEC_HIDDEN;
-/* Creates a new link context with extra bytes. The context refers to linked
+/* Creates a new link context. The context refers to linked
* rather than owning its own properties. If addRef is TRUE (which ordinarily
* it should be) linked is addref'd.
* Free with Context_Release.
*/
-context_t *Context_CreateLinkContext(unsigned contextSize, context_t *linked, unsigned extra) DECLSPEC_HIDDEN;
-
-/* Returns a pointer to the extra bytes allocated with context, which must be
- * a link context.
- */
-void *Context_GetExtra(const void *context, size_t contextSize) DECLSPEC_HIDDEN;
+context_t *Context_CreateLinkContext(unsigned contextSize, context_t *linked) DECLSPEC_HIDDEN;
/* Gets the context linked to by context, which must be a link context. */
void *Context_GetLinkedContext(void*) DECLSPEC_HIDDEN;
More information about the wine-cvs
mailing list