Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-winehq
Commits
12982d86
Commit
12982d86
authored
Oct 08, 2013
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 08, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Use BASE_CONTEXT for both data and link contexts.
parent
5674f166
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
29 deletions
+18
-29
context.c
dlls/crypt32/context.c
+18
-29
No files found.
dlls/crypt32/context.c
View file @
12982d86
...
@@ -35,37 +35,27 @@ typedef struct _BASE_CONTEXT
...
@@ -35,37 +35,27 @@ typedef struct _BASE_CONTEXT
{
{
LONG
ref
;
LONG
ref
;
ContextType
type
;
ContextType
type
;
union
{
CONTEXT_PROPERTY_LIST
*
properties
;
struct
_BASE_CONTEXT
*
linked
;
}
u
;
}
BASE_CONTEXT
;
}
BASE_CONTEXT
;
typedef
struct
_DATA_CONTEXT
{
LONG
ref
;
ContextType
type
;
/* always ContextTypeData */
CONTEXT_PROPERTY_LIST
*
properties
;
}
DATA_CONTEXT
;
typedef
struct
_LINK_CONTEXT
{
LONG
ref
;
ContextType
type
;
/* always ContextTypeLink */
BASE_CONTEXT
*
linked
;
}
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) (BASE_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
)
{
{
void
*
ret
=
CryptMemAlloc
(
contextSize
+
sizeof
(
DATA
_CONTEXT
));
void
*
ret
=
CryptMemAlloc
(
contextSize
+
sizeof
(
BASE
_CONTEXT
));
if
(
ret
)
if
(
ret
)
{
{
DATA_CONTEXT
*
context
=
(
DATA
_CONTEXT
*
)((
LPBYTE
)
ret
+
contextSize
);
BASE_CONTEXT
*
context
=
(
BASE
_CONTEXT
*
)((
LPBYTE
)
ret
+
contextSize
);
context
->
ref
=
1
;
context
->
ref
=
1
;
context
->
type
=
ContextTypeData
;
context
->
type
=
ContextTypeData
;
context
->
properties
=
ContextPropertyList_Create
();
context
->
u
.
properties
=
ContextPropertyList_Create
();
if
(
!
context
->
properties
)
if
(
!
context
->
u
.
properties
)
{
{
CryptMemFree
(
ret
);
CryptMemFree
(
ret
);
ret
=
NULL
;
ret
=
NULL
;
...
@@ -78,13 +68,13 @@ void *Context_CreateDataContext(size_t contextSize)
...
@@ -78,13 +68,13 @@ void *Context_CreateDataContext(size_t contextSize)
void
*
Context_CreateLinkContext
(
unsigned
int
contextSize
,
void
*
linked
,
unsigned
int
extra
,
void
*
Context_CreateLinkContext
(
unsigned
int
contextSize
,
void
*
linked
,
unsigned
int
extra
,
BOOL
addRef
)
BOOL
addRef
)
{
{
void
*
context
=
CryptMemAlloc
(
contextSize
+
sizeof
(
LINK
_CONTEXT
)
+
extra
);
void
*
context
=
CryptMemAlloc
(
contextSize
+
sizeof
(
BASE
_CONTEXT
)
+
extra
);
TRACE
(
"(%d, %p, %d)
\n
"
,
contextSize
,
linked
,
extra
);
TRACE
(
"(%d, %p, %d)
\n
"
,
contextSize
,
linked
,
extra
);
if
(
context
)
if
(
context
)
{
{
LINK_CONTEXT
*
linkContext
=
(
LINK
_CONTEXT
*
)
BASE_CONTEXT_FROM_CONTEXT
(
BASE_CONTEXT
*
linkContext
=
(
BASE
_CONTEXT
*
)
BASE_CONTEXT_FROM_CONTEXT
(
context
,
contextSize
);
context
,
contextSize
);
BASE_CONTEXT
*
linkedBase
=
BASE_CONTEXT_FROM_CONTEXT
(
linked
,
BASE_CONTEXT
*
linkedBase
=
BASE_CONTEXT_FROM_CONTEXT
(
linked
,
contextSize
);
contextSize
);
...
@@ -92,7 +82,7 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned
...
@@ -92,7 +82,7 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned
memcpy
(
context
,
linked
,
contextSize
);
memcpy
(
context
,
linked
,
contextSize
);
linkContext
->
ref
=
1
;
linkContext
->
ref
=
1
;
linkContext
->
type
=
ContextTypeLink
;
linkContext
->
type
=
ContextTypeLink
;
linkContext
->
linked
=
linkedBase
;
linkContext
->
u
.
linked
=
linkedBase
;
if
(
addRef
)
if
(
addRef
)
Context_AddRef
(
linked
,
contextSize
);
Context_AddRef
(
linked
,
contextSize
);
TRACE
(
"%p's ref count is %d
\n
"
,
context
,
linkContext
->
ref
);
TRACE
(
"%p's ref count is %d
\n
"
,
context
,
linkContext
->
ref
);
...
@@ -144,7 +134,7 @@ void *Context_GetExtra(const void *context, size_t contextSize)
...
@@ -144,7 +134,7 @@ void *Context_GetExtra(const void *context, size_t contextSize)
BASE_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
(
BASE
_CONTEXT
);
}
}
void
*
Context_GetLinkedContext
(
void
*
context
,
size_t
contextSize
)
void
*
Context_GetLinkedContext
(
void
*
context
,
size_t
contextSize
)
...
@@ -152,7 +142,7 @@ void *Context_GetLinkedContext(void *context, size_t contextSize)
...
@@ -152,7 +142,7 @@ void *Context_GetLinkedContext(void *context, size_t contextSize)
BASE_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
(
((
LINK_CONTEXT
*
)
baseContext
)
->
linked
,
contextSize
);
return
CONTEXT_FROM_BASE_CONTEXT
(
baseContext
->
u
.
linked
,
contextSize
);
}
}
CONTEXT_PROPERTY_LIST
*
Context_GetProperties
(
const
void
*
context
,
size_t
contextSize
)
CONTEXT_PROPERTY_LIST
*
Context_GetProperties
(
const
void
*
context
,
size_t
contextSize
)
...
@@ -160,8 +150,8 @@ CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context, size_t context
...
@@ -160,8 +150,8 @@ CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context, size_t context
BASE_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
=
((
LINK_CONTEXT
*
)
ptr
)
->
linked
;
ptr
=
ptr
->
u
.
linked
;
return
(
ptr
&&
ptr
->
type
==
ContextTypeData
)
?
((
DATA_CONTEXT
*
)
ptr
)
->
properties
:
NULL
;
return
(
ptr
&&
ptr
->
type
==
ContextTypeData
)
?
ptr
->
u
.
properties
:
NULL
;
}
}
BOOL
Context_Release
(
void
*
context
,
size_t
contextSize
,
BOOL
Context_Release
(
void
*
context
,
size_t
contextSize
,
...
@@ -181,15 +171,14 @@ BOOL Context_Release(void *context, size_t contextSize,
...
@@ -181,15 +171,14 @@ 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
(
((
LINK_CONTEXT
*
)
base
)
->
linked
,
contextSize
),
contextSize
,
base
->
u
.
linked
,
contextSize
),
contextSize
,
dataContextFree
);
dataContextFree
);
}
}
if
(
InterlockedDecrement
(
&
base
->
ref
)
==
0
)
if
(
InterlockedDecrement
(
&
base
->
ref
)
==
0
)
{
{
TRACE
(
"freeing %p
\n
"
,
context
);
TRACE
(
"freeing %p
\n
"
,
context
);
if
(
base
->
type
==
ContextTypeData
)
if
(
base
->
type
==
ContextTypeData
)
{
{
ContextPropertyList_Free
(
((
DATA_CONTEXT
*
)
base
)
->
properties
);
ContextPropertyList_Free
(
base
->
u
.
properties
);
dataContextFree
(
context
);
dataContextFree
(
context
);
}
}
CryptMemFree
(
context
);
CryptMemFree
(
context
);
...
@@ -249,7 +238,7 @@ static inline struct list *ContextList_ContextToEntry(const struct ContextList *
...
@@ -249,7 +238,7 @@ static inline struct list *ContextList_ContextToEntry(const struct ContextList *
static
inline
void
*
ContextList_EntryToContext
(
const
struct
ContextList
*
list
,
static
inline
void
*
ContextList_EntryToContext
(
const
struct
ContextList
*
list
,
struct
list
*
entry
)
struct
list
*
entry
)
{
{
return
(
LPBYTE
)
entry
-
sizeof
(
LINK
_CONTEXT
)
-
list
->
contextSize
;
return
(
LPBYTE
)
entry
-
sizeof
(
BASE
_CONTEXT
)
-
list
->
contextSize
;
}
}
void
*
ContextList_Add
(
struct
ContextList
*
list
,
void
*
toLink
,
void
*
toReplace
)
void
*
ContextList_Add
(
struct
ContextList
*
list
,
void
*
toLink
,
void
*
toReplace
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment