crypt32: Store extra pointer directly in context_t and get rid of Context_GetExtra.
This commit is contained in:
parent
06f5ee4b2c
commit
03ff35c270
|
@ -72,14 +72,15 @@ static DWORD Collection_release(WINECRYPT_CERTSTORE *store, DWORD flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *CRYPT_CollectionCreateContextFromChild(WINE_COLLECTIONSTORE *store,
|
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),
|
context_t *ret;
|
||||||
sizeof(WINE_STORE_LIST_ENTRY*));
|
|
||||||
|
|
||||||
if (ret)
|
ret = Context_CreateLinkContext(contextSize, child);
|
||||||
*(WINE_STORE_LIST_ENTRY **)Context_GetExtra(context_ptr(ret), contextSize) = storeEntry;
|
if (!ret)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
ret->u.ptr = storeEntry;
|
||||||
return context_ptr(ret);
|
return context_ptr(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -100,8 +101,7 @@ static BOOL CRYPT_CollectionAddContext(WINE_COLLECTIONSTORE *store,
|
||||||
void *existingLinked = Context_GetLinkedContext(toReplace);
|
void *existingLinked = Context_GetLinkedContext(toReplace);
|
||||||
CONTEXT_FUNCS *contextFuncs;
|
CONTEXT_FUNCS *contextFuncs;
|
||||||
|
|
||||||
storeEntry = *(WINE_STORE_LIST_ENTRY **)Context_GetExtra(toReplace,
|
storeEntry = context_from_ptr(toReplace)->u.ptr;
|
||||||
contextSize);
|
|
||||||
contextFuncs = (CONTEXT_FUNCS*)((LPBYTE)storeEntry->store->vtbl +
|
contextFuncs = (CONTEXT_FUNCS*)((LPBYTE)storeEntry->store->vtbl +
|
||||||
contextFuncsOffset);
|
contextFuncsOffset);
|
||||||
ret = contextFuncs->addContext(storeEntry->store, context,
|
ret = contextFuncs->addContext(storeEntry->store, context,
|
||||||
|
@ -166,7 +166,7 @@ static void *CRYPT_CollectionAdvanceEnum(WINE_COLLECTIONSTORE *store,
|
||||||
else
|
else
|
||||||
child = contextFuncs->enumContext(storeEntry->store, NULL);
|
child = contextFuncs->enumContext(storeEntry->store, NULL);
|
||||||
if (child) {
|
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));
|
Context_Release(context_from_ptr(child));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -206,10 +206,9 @@ static BOOL Collection_addCert(WINECRYPT_CERTSTORE *store, void *cert,
|
||||||
cert, toReplace, sizeof(CERT_CONTEXT), &childContext);
|
cert, toReplace, sizeof(CERT_CONTEXT), &childContext);
|
||||||
if (ppStoreContext && childContext)
|
if (ppStoreContext && childContext)
|
||||||
{
|
{
|
||||||
WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **)
|
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
|
||||||
Context_GetExtra(childContext, sizeof(CERT_CONTEXT));
|
|
||||||
PCERT_CONTEXT context =
|
PCERT_CONTEXT context =
|
||||||
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CERT_CONTEXT));
|
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CERT_CONTEXT));
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
context->hCertStore = store;
|
context->hCertStore = store;
|
||||||
|
@ -229,9 +228,7 @@ static void *Collection_enumCert(WINECRYPT_CERTSTORE *store, void *pPrev)
|
||||||
EnterCriticalSection(&cs->cs);
|
EnterCriticalSection(&cs->cs);
|
||||||
if (pPrev)
|
if (pPrev)
|
||||||
{
|
{
|
||||||
WINE_STORE_LIST_ENTRY *storeEntry =
|
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(pPrev)->u.ptr;
|
||||||
*(WINE_STORE_LIST_ENTRY **)Context_GetExtra(pPrev,
|
|
||||||
sizeof(CERT_CONTEXT));
|
|
||||||
|
|
||||||
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
|
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
|
||||||
&storeEntry->store->vtbl->certs, pCertInterface, pPrev,
|
&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);
|
crl, toReplace, sizeof(CRL_CONTEXT), &childContext);
|
||||||
if (ppStoreContext && childContext)
|
if (ppStoreContext && childContext)
|
||||||
{
|
{
|
||||||
WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **)
|
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
|
||||||
Context_GetExtra(childContext, sizeof(CRL_CONTEXT));
|
|
||||||
PCRL_CONTEXT context =
|
PCRL_CONTEXT context =
|
||||||
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CRL_CONTEXT));
|
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CRL_CONTEXT));
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
context->hCertStore = store;
|
context->hCertStore = store;
|
||||||
|
@ -308,9 +304,7 @@ static void *Collection_enumCRL(WINECRYPT_CERTSTORE *store, void *pPrev)
|
||||||
EnterCriticalSection(&cs->cs);
|
EnterCriticalSection(&cs->cs);
|
||||||
if (pPrev)
|
if (pPrev)
|
||||||
{
|
{
|
||||||
WINE_STORE_LIST_ENTRY *storeEntry =
|
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(pPrev)->u.ptr;
|
||||||
*(WINE_STORE_LIST_ENTRY **)Context_GetExtra(pPrev,
|
|
||||||
sizeof(CRL_CONTEXT));
|
|
||||||
|
|
||||||
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
|
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
|
||||||
&storeEntry->store->vtbl->crls, pCRLInterface, pPrev, sizeof(CRL_CONTEXT));
|
&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);
|
ctl, toReplace, sizeof(CTL_CONTEXT), &childContext);
|
||||||
if (ppStoreContext && childContext)
|
if (ppStoreContext && childContext)
|
||||||
{
|
{
|
||||||
WINE_STORE_LIST_ENTRY *storeEntry = *(WINE_STORE_LIST_ENTRY **)
|
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(childContext)->u.ptr;
|
||||||
Context_GetExtra(childContext, sizeof(CTL_CONTEXT));
|
|
||||||
PCTL_CONTEXT context =
|
PCTL_CONTEXT context =
|
||||||
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, childContext, sizeof(CTL_CONTEXT));
|
CRYPT_CollectionCreateContextFromChild(cs, storeEntry, context_from_ptr(childContext), sizeof(CTL_CONTEXT));
|
||||||
|
|
||||||
if (context)
|
if (context)
|
||||||
context->hCertStore = store;
|
context->hCertStore = store;
|
||||||
|
@ -386,8 +379,7 @@ static void *Collection_enumCTL(WINECRYPT_CERTSTORE *store, void *pPrev)
|
||||||
EnterCriticalSection(&cs->cs);
|
EnterCriticalSection(&cs->cs);
|
||||||
if (pPrev)
|
if (pPrev)
|
||||||
{
|
{
|
||||||
WINE_STORE_LIST_ENTRY *storeEntry =
|
WINE_STORE_LIST_ENTRY *storeEntry = context_from_ptr(pPrev)->u.ptr;
|
||||||
*(WINE_STORE_LIST_ENTRY **)Context_GetExtra(pPrev, sizeof(CTL_CONTEXT));
|
|
||||||
|
|
||||||
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
|
ret = CRYPT_CollectionAdvanceEnum(cs, storeEntry,
|
||||||
&storeEntry->store->vtbl->ctls, pCTLInterface, pPrev, sizeof(CTL_CONTEXT));
|
&storeEntry->store->vtbl->ctls, pCTLInterface, pPrev, sizeof(CTL_CONTEXT));
|
||||||
|
|
|
@ -50,13 +50,13 @@ void *Context_CreateDataContext(size_t contextSize, const context_vtbl_t *vtbl)
|
||||||
return CONTEXT_FROM_BASE_CONTEXT(context);
|
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;
|
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)
|
if (!context)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
@ -168,7 +168,7 @@ void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace)
|
||||||
|
|
||||||
TRACE("(%p, %p, %p)\n", list, toLink, 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)
|
if (context)
|
||||||
{
|
{
|
||||||
TRACE("adding %p\n", context);
|
TRACE("adding %p\n", context);
|
||||||
|
|
|
@ -174,6 +174,7 @@ typedef struct _context_t {
|
||||||
CONTEXT_PROPERTY_LIST *properties;
|
CONTEXT_PROPERTY_LIST *properties;
|
||||||
union {
|
union {
|
||||||
struct list entry;
|
struct list entry;
|
||||||
|
void *ptr;
|
||||||
} u;
|
} u;
|
||||||
} BASE_CONTEXT;
|
} 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;
|
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
|
* rather than owning its own properties. If addRef is TRUE (which ordinarily
|
||||||
* it should be) linked is addref'd.
|
* it should be) linked is addref'd.
|
||||||
* Free with Context_Release.
|
* Free with Context_Release.
|
||||||
*/
|
*/
|
||||||
context_t *Context_CreateLinkContext(unsigned contextSize, context_t *linked, unsigned extra) DECLSPEC_HIDDEN;
|
context_t *Context_CreateLinkContext(unsigned contextSize, context_t *linked) 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;
|
|
||||||
|
|
||||||
/* Gets the context linked to by context, which must be a link context. */
|
/* Gets the context linked to by context, which must be a link context. */
|
||||||
void *Context_GetLinkedContext(void*) DECLSPEC_HIDDEN;
|
void *Context_GetLinkedContext(void*) DECLSPEC_HIDDEN;
|
||||||
|
|
Loading…
Reference in New Issue