[Pcsclite-cvs-commit] r2462 - trunk/PCSC/src

Ludovic Rousseau rousseau at alioth.debian.org
Tue Mar 6 09:46:33 CET 2007


Author: rousseau
Date: 2007-03-06 08:46:32 +0000 (Tue, 06 Mar 2007)
New Revision: 2462

Modified:
   trunk/PCSC/src/winscard_clnt.c
Log:
move code from SCardRemoveContext() to a new function
SCardCleanContext() and call it from SCardRemoveContext()


Modified: trunk/PCSC/src/winscard_clnt.c
===================================================================
--- trunk/PCSC/src/winscard_clnt.c	2007-03-06 08:35:45 UTC (rev 2461)
+++ trunk/PCSC/src/winscard_clnt.c	2007-03-06 08:46:32 UTC (rev 2462)
@@ -187,6 +187,7 @@
 static LONG SCardGetContextIndice(SCARDCONTEXT);
 static LONG SCardGetContextIndiceTH(SCARDCONTEXT);
 static LONG SCardRemoveContext(SCARDCONTEXT);
+static LONG SCardCleanContext(LONG indice);
 
 static LONG SCardAddHandle(SCARDHANDLE, DWORD, LPSTR);
 static LONG SCardGetIndicesFromHandle(SCARDHANDLE, PDWORD, PDWORD);
@@ -3194,28 +3195,31 @@
 	if (retIndice == -1)
 		return SCARD_E_INVALID_HANDLE;
 	else
-	{
-		int i;
+		return SCardCleanContext(retIndice);
+}
 
-		psContextMap[retIndice].hContext = 0;
-		SHMClientCloseSession(psContextMap[retIndice].dwClientID);
-		psContextMap[retIndice].dwClientID = 0;
-		free(psContextMap[retIndice].mMutex);
-		psContextMap[retIndice].mMutex = NULL;
-		psContextMap[retIndice].contextBlockStatus = BLOCK_STATUS_RESUME;
+static LONG SCardCleanContext(LONG indice)
+{
+	int i;
 
-		for (i = 0; i < PCSCLITE_MAX_APPLICATION_CONTEXT_CHANNELS; i++)
-		{
-			/*
-			 * Reset the \c hCard structs to zero
-			 */
-			psContextMap[retIndice].psChannelMap[i].hCard = 0;
-			free(psContextMap[retIndice].psChannelMap[i].readerName);
-			psContextMap[retIndice].psChannelMap[i].readerName = NULL;
-		}
+	psContextMap[indice].hContext = 0;
+	SHMClientCloseSession(psContextMap[indice].dwClientID);
+	psContextMap[indice].dwClientID = 0;
+	free(psContextMap[indice].mMutex);
+	psContextMap[indice].mMutex = NULL;
+	psContextMap[indice].contextBlockStatus = BLOCK_STATUS_RESUME;
 
-		return SCARD_S_SUCCESS;
+	for (i = 0; i < PCSCLITE_MAX_APPLICATION_CONTEXT_CHANNELS; i++)
+	{
+		/*
+		 * Reset the \c hCard structs to zero
+		 */
+		psContextMap[indice].psChannelMap[i].hCard = 0;
+		free(psContextMap[indice].psChannelMap[i].readerName);
+		psContextMap[indice].psChannelMap[i].readerName = NULL;
 	}
+
+	return SCARD_S_SUCCESS;
 }
 
 /*




More information about the Pcsclite-cvs-commit mailing list