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
993691be
Commit
993691be
authored
Oct 14, 2013
by
Jacek Caban
Committed by
Alexandre Julliard
Oct 14, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
crypt32: Moved context desatructor to vtbl.
parent
17e1dfef
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
61 additions
and
42 deletions
+61
-42
cert.c
dlls/crypt32/cert.c
+14
-10
context.c
dlls/crypt32/context.c
+6
-4
crl.c
dlls/crypt32/crl.c
+14
-10
crypt32_private.h
dlls/crypt32/crypt32_private.h
+11
-6
ctl.c
dlls/crypt32/ctl.c
+16
-12
No files found.
dlls/crypt32/cert.c
View file @
993691be
...
...
@@ -109,6 +109,18 @@ BOOL WINAPI CertAddEncodedCertificateToSystemStoreW(LPCWSTR pszCertStoreName,
return
ret
;
}
static
void
Cert_free
(
context_t
*
context
)
{
cert_t
*
cert
=
(
cert_t
*
)
context
;
CryptMemFree
(
cert
->
ctx
.
pbCertEncoded
);
LocalFree
(
cert
->
ctx
.
pCertInfo
);
}
static
const
context_vtbl_t
cert_vtbl
=
{
Cert_free
};
BOOL
WINAPI
CertAddCertificateLinkToStore
(
HCERTSTORE
hCertStore
,
PCCERT_CONTEXT
pCertContext
,
DWORD
dwAddDisposition
,
PCCERT_CONTEXT
*
ppCertContext
)
...
...
@@ -154,7 +166,7 @@ PCCERT_CONTEXT WINAPI CertCreateCertificateContext(DWORD dwCertEncodingType,
{
BYTE
*
data
=
NULL
;
cert
=
Context_CreateDataContext
(
sizeof
(
CERT_CONTEXT
));
cert
=
Context_CreateDataContext
(
sizeof
(
CERT_CONTEXT
)
,
&
cert_vtbl
);
if
(
!
cert
)
goto
end
;
data
=
CryptMemAlloc
(
cbCertEncoded
);
...
...
@@ -187,14 +199,6 @@ PCCERT_CONTEXT WINAPI CertDuplicateCertificateContext(PCCERT_CONTEXT pCertContex
return
pCertContext
;
}
static
void
CertDataContext_Free
(
void
*
context
)
{
PCERT_CONTEXT
certContext
=
context
;
CryptMemFree
(
certContext
->
pbCertEncoded
);
LocalFree
(
certContext
->
pCertInfo
);
}
BOOL
WINAPI
CertFreeCertificateContext
(
PCCERT_CONTEXT
pCertContext
)
{
BOOL
ret
=
TRUE
;
...
...
@@ -202,7 +206,7 @@ BOOL WINAPI CertFreeCertificateContext(PCCERT_CONTEXT pCertContext)
TRACE
(
"(%p)
\n
"
,
pCertContext
);
if
(
pCertContext
)
ret
=
Context_Release
(
&
cert_from_ptr
(
pCertContext
)
->
base
,
CertDataContext_Free
);
ret
=
Context_Release
(
&
cert_from_ptr
(
pCertContext
)
->
base
);
return
ret
;
}
...
...
dlls/crypt32/context.c
View file @
993691be
...
...
@@ -29,7 +29,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(context);
#define CONTEXT_FROM_BASE_CONTEXT(p) (void*)(p+1)
#define BASE_CONTEXT_FROM_CONTEXT(p) ((BASE_CONTEXT*)(p)-1)
void
*
Context_CreateDataContext
(
size_t
contextSize
)
void
*
Context_CreateDataContext
(
size_t
contextSize
,
const
context_vtbl_t
*
vtbl
)
{
BASE_CONTEXT
*
context
;
...
...
@@ -37,6 +37,7 @@ void *Context_CreateDataContext(size_t contextSize)
if
(
!
context
)
return
NULL
;
context
->
vtbl
=
vtbl
;
context
->
ref
=
1
;
context
->
linked
=
NULL
;
context
->
properties
=
ContextPropertyList_Create
();
...
...
@@ -62,6 +63,7 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned
return
NULL
;
memcpy
(
CONTEXT_FROM_BASE_CONTEXT
(
context
),
linked
,
contextSize
);
context
->
vtbl
=
BASE_CONTEXT_FROM_CONTEXT
(
linked
)
->
vtbl
;
context
->
ref
=
1
;
context
->
linked
=
BASE_CONTEXT_FROM_CONTEXT
(
linked
);
if
(
addRef
)
...
...
@@ -103,7 +105,7 @@ CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context)
return
ptr
->
properties
;
}
BOOL
Context_Release
(
context_t
*
context
,
ContextFreeFunc
dataContextFree
)
BOOL
Context_Release
(
context_t
*
context
)
{
BOOL
ret
=
TRUE
;
...
...
@@ -118,9 +120,9 @@ BOOL Context_Release(context_t *context, ContextFreeFunc dataContextFree)
if
(
!
context
->
linked
)
{
ContextPropertyList_Free
(
context
->
properties
);
dataContextFree
(
CONTEXT_FROM_BASE_CONTEXT
(
context
)
);
context
->
vtbl
->
free
(
context
);
}
else
{
Context_Release
(
context
->
linked
,
dataContextFree
);
Context_Release
(
context
->
linked
);
}
CryptMemFree
(
context
);
}
...
...
dlls/crypt32/crl.c
View file @
993691be
...
...
@@ -29,6 +29,18 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
crypt
);
static
void
CRL_free
(
context_t
*
context
)
{
crl_t
*
crl
=
(
crl_t
*
)
context
;
CryptMemFree
(
crl
->
ctx
.
pbCrlEncoded
);
LocalFree
(
crl
->
ctx
.
pCrlInfo
);
}
static
const
context_vtbl_t
crl_vtbl
=
{
CRL_free
};
PCCRL_CONTEXT
WINAPI
CertCreateCRLContext
(
DWORD
dwCertEncodingType
,
const
BYTE
*
pbCrlEncoded
,
DWORD
cbCrlEncoded
)
{
...
...
@@ -52,7 +64,7 @@ PCCRL_CONTEXT WINAPI CertCreateCRLContext(DWORD dwCertEncodingType,
{
BYTE
*
data
=
NULL
;
crl
=
Context_CreateDataContext
(
sizeof
(
CRL_CONTEXT
));
crl
=
Context_CreateDataContext
(
sizeof
(
CRL_CONTEXT
)
,
&
crl_vtbl
);
if
(
!
crl
)
goto
end
;
data
=
CryptMemAlloc
(
cbCrlEncoded
);
...
...
@@ -331,14 +343,6 @@ PCCRL_CONTEXT WINAPI CertDuplicateCRLContext(PCCRL_CONTEXT pCrlContext)
return
pCrlContext
;
}
static
void
CrlDataContext_Free
(
void
*
context
)
{
PCRL_CONTEXT
crlContext
=
context
;
CryptMemFree
(
crlContext
->
pbCrlEncoded
);
LocalFree
(
crlContext
->
pCrlInfo
);
}
BOOL
WINAPI
CertFreeCRLContext
(
PCCRL_CONTEXT
pCrlContext
)
{
BOOL
ret
=
TRUE
;
...
...
@@ -346,7 +350,7 @@ BOOL WINAPI CertFreeCRLContext( PCCRL_CONTEXT pCrlContext)
TRACE
(
"(%p)
\n
"
,
pCrlContext
);
if
(
pCrlContext
)
ret
=
Context_Release
(
&
crl_from_ptr
(
pCrlContext
)
->
base
,
CrlDataContext_Free
);
ret
=
Context_Release
(
&
crl_from_ptr
(
pCrlContext
)
->
base
);
return
ret
;
}
...
...
dlls/crypt32/crypt32_private.h
View file @
993691be
...
...
@@ -159,11 +159,18 @@ void default_chain_engine_free(void) DECLSPEC_HIDDEN;
typedef
struct
_CONTEXT_PROPERTY_LIST
CONTEXT_PROPERTY_LIST
;
typedef
struct
_context_t
context_t
;
typedef
struct
{
void
(
*
free
)(
context_t
*
);
}
context_vtbl_t
;
typedef
struct
_context_t
{
const
context_vtbl_t
*
vtbl
;
LONG
ref
;
struct
_context_t
*
linked
;
CONTEXT_PROPERTY_LIST
*
properties
;
}
BASE_CONTEXT
,
context_t
;
}
BASE_CONTEXT
;
static
inline
context_t
*
context_from_ptr
(
const
void
*
ptr
)
{
...
...
@@ -380,7 +387,7 @@ DWORD cert_name_to_str_with_indent(DWORD dwCertEncodingType, DWORD indent,
* which should be one of CERT_CONTEXT, CRL_CONTEXT, or CTL_CONTEXT.
* Free with Context_Release.
*/
void
*
Context_CreateDataContext
(
size_t
contextSize
)
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
* rather than owning its own properties. If addRef is TRUE (which ordinarily
...
...
@@ -396,7 +403,7 @@ void *Context_CreateLinkContext(unsigned int contextSize, void *linked, unsigned
void
*
Context_GetExtra
(
const
void
*
context
,
size_t
contextSize
)
DECLSPEC_HIDDEN
;
/* Gets the context linked to by context, which must be a link context. */
void
*
Context_GetLinkedContext
(
void
*
context
)
DECLSPEC_HIDDEN
;
void
*
Context_GetLinkedContext
(
void
*
)
DECLSPEC_HIDDEN
;
/* Copies properties from fromContext to toContext. */
void
Context_CopyProperties
(
const
void
*
to
,
const
void
*
from
)
DECLSPEC_HIDDEN
;
...
...
@@ -408,14 +415,12 @@ CONTEXT_PROPERTY_LIST *Context_GetProperties(const void *context) DECLSPEC_HIDDE
void
Context_AddRef
(
context_t
*
)
DECLSPEC_HIDDEN
;
typedef
void
(
*
ContextFreeFunc
)(
void
*
context
);
/* Decrements context's ref count. If context is a link context, releases its
* linked context as well.
* If a data context has its ref count reach 0, calls dataContextFree on it.
* Returns FALSE if the reference count is <= 0 when called.
*/
BOOL
Context_Release
(
context_t
*
context
,
ContextFreeFunc
dataContextFree
)
DECLSPEC_HIDDEN
;
BOOL
Context_Release
(
context_t
*
context
)
DECLSPEC_HIDDEN
;
/**
* Context property list functions
...
...
dlls/crypt32/ctl.c
View file @
993691be
...
...
@@ -29,6 +29,20 @@
WINE_DEFAULT_DEBUG_CHANNEL
(
crypt
);
static
void
CTL_free
(
context_t
*
context
)
{
ctl_t
*
ctl
=
(
ctl_t
*
)
context
;
CryptMsgClose
(
ctl
->
ctx
.
hCryptMsg
);
CryptMemFree
(
ctl
->
ctx
.
pbCtlEncoded
);
CryptMemFree
(
ctl
->
ctx
.
pbCtlContext
);
LocalFree
(
ctl
->
ctx
.
pCtlInfo
);
}
static
const
context_vtbl_t
ctl_vtbl
=
{
CTL_free
};
BOOL
WINAPI
CertAddCTLContextToStore
(
HCERTSTORE
hCertStore
,
PCCTL_CONTEXT
pCtlContext
,
DWORD
dwAddDisposition
,
PCCTL_CONTEXT
*
ppStoreContext
)
...
...
@@ -403,7 +417,7 @@ PCCTL_CONTEXT WINAPI CertCreateCTLContext(DWORD dwMsgAndCertEncodingType,
&
ctlInfo
,
&
size
);
if
(
ret
)
{
ctl
=
Context_CreateDataContext
(
sizeof
(
CTL_CONTEXT
));
ctl
=
Context_CreateDataContext
(
sizeof
(
CTL_CONTEXT
)
,
&
ctl_vtbl
);
if
(
ctl
)
{
BYTE
*
data
=
CryptMemAlloc
(
cbCtlEncoded
);
...
...
@@ -461,16 +475,6 @@ PCCTL_CONTEXT WINAPI CertDuplicateCTLContext(PCCTL_CONTEXT pCtlContext)
return
pCtlContext
;
}
static
void
CTLDataContext_Free
(
void
*
context
)
{
PCTL_CONTEXT
ctlContext
=
context
;
CryptMsgClose
(
ctlContext
->
hCryptMsg
);
CryptMemFree
(
ctlContext
->
pbCtlEncoded
);
CryptMemFree
(
ctlContext
->
pbCtlContext
);
LocalFree
(
ctlContext
->
pCtlInfo
);
}
BOOL
WINAPI
CertFreeCTLContext
(
PCCTL_CONTEXT
pCTLContext
)
{
BOOL
ret
=
TRUE
;
...
...
@@ -478,7 +482,7 @@ BOOL WINAPI CertFreeCTLContext(PCCTL_CONTEXT pCTLContext)
TRACE
(
"(%p)
\n
"
,
pCTLContext
);
if
(
pCTLContext
)
ret
=
Context_Release
(
&
ctl_from_ptr
(
pCTLContext
)
->
base
,
CTLDataContext_Free
);
ret
=
Context_Release
(
&
ctl_from_ptr
(
pCTLContext
)
->
base
);
return
ret
;
}
...
...
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