Commit 802a6bc1 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Pass context as BASE_CONTEXT to Context_AddRef and added structs…

crypt32: Pass context as BASE_CONTEXT to Context_AddRef and added structs describing memory layout behind context structs.
parent b2b71c20
......@@ -176,15 +176,14 @@ end:
return cert;
}
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(
PCCERT_CONTEXT pCertContext)
PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContext)
{
TRACE("(%p)\n", pCertContext);
if (!pCertContext)
return NULL;
Context_AddRef((void *)pCertContext);
Context_AddRef(&cert_from_ptr(pCertContext)->base);
return pCertContext;
}
......
......@@ -26,13 +26,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(context);
typedef struct _BASE_CONTEXT
{
LONG ref;
struct _BASE_CONTEXT *linked;
CONTEXT_PROPERTY_LIST *properties;
} BASE_CONTEXT;
#define CONTEXT_FROM_BASE_CONTEXT(p) (void*)(p+1)
#define BASE_CONTEXT_FROM_CONTEXT(p) ((BASE_CONTEXT*)(p)-1)
......@@ -72,18 +65,16 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned
context->ref = 1;
context->linked = BASE_CONTEXT_FROM_CONTEXT(linked);
if (addRef)
Context_AddRef(linked);
Context_AddRef(BASE_CONTEXT_FROM_CONTEXT(linked));
TRACE("returning %p\n", context);
return CONTEXT_FROM_BASE_CONTEXT(context);
}
void Context_AddRef(void *context)
void Context_AddRef(context_t *context)
{
BASE_CONTEXT *baseContext = BASE_CONTEXT_FROM_CONTEXT(context);
InterlockedIncrement(&baseContext->ref);
TRACE("%p's ref count is %d\n", context, baseContext->ref);
InterlockedIncrement(&context->ref);
TRACE("(%p) ref=%d\n", context, context->ref);
}
void *Context_GetExtra(const void *context, size_t contextSize)
......
......@@ -327,7 +327,7 @@ PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext)
{
TRACE("(%p)\n", pCrlContext);
if (pCrlContext)
Context_AddRef((void *)pCrlContext);
Context_AddRef(&crl_from_ptr(pCrlContext)->base);
return pCrlContext;
}
......
......@@ -157,6 +157,49 @@ void crypt_sip_free(void) DECLSPEC_HIDDEN;
void root_store_free(void) DECLSPEC_HIDDEN;
void default_chain_engine_free(void) DECLSPEC_HIDDEN;
typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
typedef struct _context_t {
LONG ref;
struct _context_t *linked;
CONTEXT_PROPERTY_LIST *properties;
} BASE_CONTEXT, context_t;
static inline context_t *context_from_ptr(const void *ptr)
{
return (context_t*)ptr-1;
}
typedef struct {
context_t base;
CERT_CONTEXT ctx;
} cert_t;
static inline cert_t *cert_from_ptr(const CERT_CONTEXT *ptr)
{
return CONTAINING_RECORD(ptr, cert_t, ctx);
}
typedef struct {
context_t base;
CRL_CONTEXT ctx;
} crl_t;
static inline crl_t *crl_from_ptr(const CRL_CONTEXT *ptr)
{
return CONTAINING_RECORD(ptr, crl_t, ctx);
}
typedef struct {
context_t base;
CTL_CONTEXT ctx;
} ctl_t;
static inline ctl_t *ctl_from_ptr(const CTL_CONTEXT *ptr)
{
return CONTAINING_RECORD(ptr, ctl_t, ctx);
}
/* Some typedefs that make it easier to abstract which type of context we're
* working with.
*/
......@@ -234,8 +277,6 @@ typedef enum _CertStoreType {
StoreTypeEmpty
} CertStoreType;
typedef struct _CONTEXT_PROPERTY_LIST CONTEXT_PROPERTY_LIST;
#define WINE_CRYPTCERTSTORE_MAGIC 0x74726563
/* A cert store is polymorphic through the use of function pointers. A type
......@@ -365,7 +406,7 @@ void Context_CopyProperties(const void *to, const void *from) DECLSPEC_HIDDEN;
*/
CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context) DECLSPEC_HIDDEN;
void Context_AddRef(void *context) DECLSPEC_HIDDEN;
void Context_AddRef(context_t*) DECLSPEC_HIDDEN;
typedef void (*ContextFreeFunc)(void *context);
......
......@@ -457,7 +457,7 @@ PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext)
{
TRACE("(%p)\n", pCtlContext);
if (pCtlContext)
Context_AddRef((void *)pCtlContext);
Context_AddRef(&ctl_from_ptr(pCtlContext)->base);
return pCtlContext;
}
......
......@@ -1507,7 +1507,7 @@ static BOOL EmptyStore_add(WINECRYPT_CERTSTORE *store, void *context,
/* FIXME: We should clone the context */
if(ret_context) {
Context_AddRef(context);
Context_AddRef(context_from_ptr(context));
*ret_context = context;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment