crypt32: Rename a function to reflect its behavior better, and return whether it succeeds.

This commit is contained in:
Juan Lang 2009-10-30 19:06:44 -07:00 committed by Alexandre Julliard
parent 7e1cff1c18
commit 108f30bb7d
4 changed files with 33 additions and 11 deletions

View File

@ -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)

View File

@ -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);

View File

@ -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)

View File

@ -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 */