Juan Lang : crypt32: Rename a function to reflect its behavior better, and return whether it succeeds.
Alexandre Julliard
julliard at winehq.org
Wed Nov 4 10:26:25 CST 2009
Module: wine
Branch: master
Commit: 108f30bb7d4f466722f7af1fa8c9c9bcfb8e3a5b
URL: http://source.winehq.org/git/wine.git/?a=commit;h=108f30bb7d4f466722f7af1fa8c9c9bcfb8e3a5b
Author: Juan Lang <juan.lang at gmail.com>
Date: Fri Oct 30 19:06:44 2009 -0700
crypt32: Rename a function to reflect its behavior better, and return whether it succeeds.
---
dlls/crypt32/context.c | 13 ++++++++++---
dlls/crypt32/crypt32_private.h | 6 +++++-
dlls/crypt32/store.c | 24 ++++++++++++++++++------
dlls/crypt32/tests/store.c | 1 -
4 files changed, 33 insertions(+), 11 deletions(-)
diff --git a/dlls/crypt32/context.c b/dlls/crypt32/context.c
index 73e1e0e..bf4ccf3 100644
--- a/dlls/crypt32/context.c
+++ b/dlls/crypt32/context.c
@@ -313,14 +313,21 @@ void *ContextList_Enum(struct ContextList *list, void *pPrev)
return ret;
}
-void ContextList_Delete(struct ContextList *list, void *context)
+BOOL ContextList_Remove(struct ContextList *list, void *context)
{
struct list *entry = ContextList_ContextToEntry(list, context);
+ BOOL inList = FALSE;
EnterCriticalSection(&list->cs);
- list_remove(entry);
+ if (!list_empty(entry))
+ {
+ list_remove(entry);
+ inList = TRUE;
+ }
LeaveCriticalSection(&list->cs);
- list_init(entry);
+ if (inList)
+ list_init(entry);
+ return inList;
}
static void ContextList_Empty(struct ContextList *list)
diff --git a/dlls/crypt32/crypt32_private.h b/dlls/crypt32/crypt32_private.h
index dd96e0f..cbdf511 100644
--- a/dlls/crypt32/crypt32_private.h
+++ b/dlls/crypt32/crypt32_private.h
@@ -388,7 +388,11 @@ void *ContextList_Add(struct ContextList *list, void *toLink, void *toReplace);
void *ContextList_Enum(struct ContextList *list, void *pPrev);
-void ContextList_Delete(struct ContextList *list, void *context);
+/* Removes a context from the list. Returns TRUE if the context was removed,
+ * or FALSE if not. (The context may have been duplicated, so subsequent
+ * removes have no effect.)
+ */
+BOOL ContextList_Remove(struct ContextList *list, void *context);
void ContextList_Free(struct ContextList *list);
diff --git a/dlls/crypt32/store.c b/dlls/crypt32/store.c
index deb0520..e1cce40 100644
--- a/dlls/crypt32/store.c
+++ b/dlls/crypt32/store.c
@@ -184,9 +184,13 @@ static void *CRYPT_MemEnumCert(PWINECRYPT_CERTSTORE store, void *pPrev)
static BOOL CRYPT_MemDeleteCert(PWINECRYPT_CERTSTORE store, void *pCertContext)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
+ BOOL ret;
- ContextList_Delete(ms->certs, pCertContext);
- return CertFreeCertificateContext(pCertContext);
+ if (ContextList_Remove(ms->certs, pCertContext))
+ ret = CertFreeCertificateContext(pCertContext);
+ else
+ ret = TRUE;
+ return ret;
}
static BOOL CRYPT_MemAddCrl(PWINECRYPT_CERTSTORE store, void *crl,
@@ -225,9 +229,13 @@ static void *CRYPT_MemEnumCrl(PWINECRYPT_CERTSTORE store, void *pPrev)
static BOOL CRYPT_MemDeleteCrl(PWINECRYPT_CERTSTORE store, void *pCrlContext)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
+ BOOL ret;
- ContextList_Delete(ms->crls, pCrlContext);
- return CertFreeCRLContext(pCrlContext);
+ if (ContextList_Remove(ms->crls, pCrlContext))
+ ret = CertFreeCRLContext(pCrlContext);
+ else
+ ret = TRUE;
+ return ret;
}
static BOOL CRYPT_MemAddCtl(PWINECRYPT_CERTSTORE store, void *ctl,
@@ -266,9 +274,13 @@ static void *CRYPT_MemEnumCtl(PWINECRYPT_CERTSTORE store, void *pPrev)
static BOOL CRYPT_MemDeleteCtl(PWINECRYPT_CERTSTORE store, void *pCtlContext)
{
WINE_MEMSTORE *ms = (WINE_MEMSTORE *)store;
+ BOOL ret;
- ContextList_Delete(ms->ctls, pCtlContext);
- return CertFreeCTLContext(pCtlContext);
+ if (ContextList_Remove(ms->ctls, pCtlContext))
+ ret = CertFreeCTLContext(pCtlContext);
+ else
+ ret = TRUE;
+ return ret;
}
static void WINAPI CRYPT_MemCloseStore(HCERTSTORE hCertStore, DWORD dwFlags)
diff --git a/dlls/crypt32/tests/store.c b/dlls/crypt32/tests/store.c
index 1f6609c..419d2dd 100644
--- a/dlls/crypt32/tests/store.c
+++ b/dlls/crypt32/tests/store.c
@@ -237,7 +237,6 @@ static void testMemStore(void)
GetLastError());
/* try deleting a copy */
ret = CertDeleteCertificateFromStore(copy);
- todo_wine
ok(ret, "CertDeleteCertificateFromStore failed: %08x\n",
GetLastError());
/* check that the store is empty */
More information about the wine-cvs
mailing list