Commit f4c8c3d6 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

crypt32: Get rid of P*_CONTEXT typedefs.

parent 8ad37f8a
...@@ -35,24 +35,24 @@ typedef struct _BASE_CONTEXT ...@@ -35,24 +35,24 @@ typedef struct _BASE_CONTEXT
{ {
LONG ref; LONG ref;
ContextType type; ContextType type;
} BASE_CONTEXT, *PBASE_CONTEXT; } BASE_CONTEXT;
typedef struct _DATA_CONTEXT typedef struct _DATA_CONTEXT
{ {
LONG ref; LONG ref;
ContextType type; /* always ContextTypeData */ ContextType type; /* always ContextTypeData */
CONTEXT_PROPERTY_LIST *properties; CONTEXT_PROPERTY_LIST *properties;
} DATA_CONTEXT, *PDATA_CONTEXT; } DATA_CONTEXT;
typedef struct _LINK_CONTEXT typedef struct _LINK_CONTEXT
{ {
LONG ref; LONG ref;
ContextType type; /* always ContextTypeLink */ ContextType type; /* always ContextTypeLink */
PBASE_CONTEXT linked; BASE_CONTEXT *linked;
} LINK_CONTEXT, *PLINK_CONTEXT; } LINK_CONTEXT;
#define CONTEXT_FROM_BASE_CONTEXT(p, s) ((LPBYTE)(p) - (s)) #define CONTEXT_FROM_BASE_CONTEXT(p, s) ((LPBYTE)(p) - (s))
#define BASE_CONTEXT_FROM_CONTEXT(p, s) (PBASE_CONTEXT)((LPBYTE)(p) + (s)) #define BASE_CONTEXT_FROM_CONTEXT(p, s) (BASE_CONTEXT*)((LPBYTE)(p) + (s))
void *Context_CreateDataContext(size_t contextSize) void *Context_CreateDataContext(size_t contextSize)
{ {
...@@ -60,7 +60,7 @@ void *Context_CreateDataContext(size_t contextSize) ...@@ -60,7 +60,7 @@ void *Context_CreateDataContext(size_t contextSize)
if (ret) if (ret)
{ {
PDATA_CONTEXT context = (PDATA_CONTEXT)((LPBYTE)ret + contextSize); DATA_CONTEXT *context = (DATA_CONTEXT*)((LPBYTE)ret + contextSize);
context->ref = 1; context->ref = 1;
context->type = ContextTypeData; context->type = ContextTypeData;
...@@ -84,9 +84,9 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned ...@@ -84,9 +84,9 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned
if (context) if (context)
{ {
PLINK_CONTEXT linkContext = (PLINK_CONTEXT)BASE_CONTEXT_FROM_CONTEXT( LINK_CONTEXT *linkContext = (LINK_CONTEXT*)BASE_CONTEXT_FROM_CONTEXT(
context, contextSize); context, contextSize);
PBASE_CONTEXT linkedBase = BASE_CONTEXT_FROM_CONTEXT(linked, BASE_CONTEXT *linkedBase = BASE_CONTEXT_FROM_CONTEXT(linked,
contextSize); contextSize);
memcpy(context, linked, contextSize); memcpy(context, linked, contextSize);
...@@ -103,14 +103,14 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned ...@@ -103,14 +103,14 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned
void Context_AddRef(void *context, size_t contextSize) void Context_AddRef(void *context, size_t contextSize)
{ {
PBASE_CONTEXT baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize); BASE_CONTEXT *baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
InterlockedIncrement(&baseContext->ref); InterlockedIncrement(&baseContext->ref);
TRACE("%p's ref count is %d\n", context, baseContext->ref); TRACE("%p's ref count is %d\n", context, baseContext->ref);
if (baseContext->type == ContextTypeLink) if (baseContext->type == ContextTypeLink)
{ {
void *linkedContext = Context_GetLinkedContext(context, contextSize); void *linkedContext = Context_GetLinkedContext(context, contextSize);
PBASE_CONTEXT linkedBase = BASE_CONTEXT_FROM_CONTEXT(linkedContext, BASE_CONTEXT *linkedBase = BASE_CONTEXT_FROM_CONTEXT(linkedContext,
contextSize); contextSize);
/* Add-ref the linked contexts too */ /* Add-ref the linked contexts too */
...@@ -141,7 +141,7 @@ void Context_AddRef(void *context, size_t contextSize) ...@@ -141,7 +141,7 @@ void Context_AddRef(void *context, size_t contextSize)
void *Context_GetExtra(const void *context, size_t contextSize) void *Context_GetExtra(const void *context, size_t contextSize)
{ {
PBASE_CONTEXT baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize); BASE_CONTEXT *baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
assert(baseContext->type == ContextTypeLink); assert(baseContext->type == ContextTypeLink);
return (LPBYTE)baseContext + sizeof(LINK_CONTEXT); return (LPBYTE)baseContext + sizeof(LINK_CONTEXT);
...@@ -149,27 +149,25 @@ void *Context_GetExtra(const void *context, size_t contextSize) ...@@ -149,27 +149,25 @@ void *Context_GetExtra(const void *context, size_t contextSize)
void *Context_GetLinkedContext(void *context, size_t contextSize) void *Context_GetLinkedContext(void *context, size_t contextSize)
{ {
PBASE_CONTEXT baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize); BASE_CONTEXT *baseContext = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
assert(baseContext->type == ContextTypeLink); assert(baseContext->type == ContextTypeLink);
return CONTEXT_FROM_BASE_CONTEXT(((PLINK_CONTEXT)baseContext)->linked, return CONTEXT_FROM_BASE_CONTEXT(((LINK_CONTEXT*)baseContext)->linked, contextSize);
contextSize);
} }
CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context, size_t contextSize) CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context, size_t contextSize)
{ {
PBASE_CONTEXT ptr = BASE_CONTEXT_FROM_CONTEXT(context, contextSize); BASE_CONTEXT *ptr = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
while (ptr && ptr->type == ContextTypeLink) while (ptr && ptr->type == ContextTypeLink)
ptr = ((PLINK_CONTEXT)ptr)->linked; ptr = ((LINK_CONTEXT*)ptr)->linked;
return (ptr && ptr->type == ContextTypeData) ? return (ptr && ptr->type == ContextTypeData) ? ((DATA_CONTEXT*)ptr)->properties : NULL;
((PDATA_CONTEXT)ptr)->properties : NULL;
} }
BOOL Context_Release(void *context, size_t contextSize, BOOL Context_Release(void *context, size_t contextSize,
ContextFreeFunc dataContextFree) ContextFreeFunc dataContextFree)
{ {
PBASE_CONTEXT base = BASE_CONTEXT_FROM_CONTEXT(context, contextSize); BASE_CONTEXT *base = BASE_CONTEXT_FROM_CONTEXT(context, contextSize);
BOOL ret = TRUE; BOOL ret = TRUE;
if (base->ref <= 0) if (base->ref <= 0)
...@@ -183,7 +181,7 @@ BOOL Context_Release(void *context, size_t contextSize, ...@@ -183,7 +181,7 @@ BOOL Context_Release(void *context, size_t contextSize,
* it as well, using the same offset and data free function. * it as well, using the same offset and data free function.
*/ */
ret = Context_Release(CONTEXT_FROM_BASE_CONTEXT( ret = Context_Release(CONTEXT_FROM_BASE_CONTEXT(
((PLINK_CONTEXT)base)->linked, contextSize), contextSize, ((LINK_CONTEXT*)base)->linked, contextSize), contextSize,
dataContextFree); dataContextFree);
} }
if (InterlockedDecrement(&base->ref) == 0) if (InterlockedDecrement(&base->ref) == 0)
...@@ -191,7 +189,7 @@ BOOL Context_Release(void *context, size_t contextSize, ...@@ -191,7 +189,7 @@ BOOL Context_Release(void *context, size_t contextSize,
TRACE("freeing %p\n", context); TRACE("freeing %p\n", context);
if (base->type == ContextTypeData) if (base->type == ContextTypeData)
{ {
ContextPropertyList_Free(((PDATA_CONTEXT)base)->properties); ContextPropertyList_Free(((DATA_CONTEXT*)base)->properties);
dataContextFree(context); dataContextFree(context);
} }
CryptMemFree(context); CryptMemFree(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