[Pcsclite-cvs-commit] CVS PCSC/src
CVS User rousseau
ludovic.rousseau@free.fr
Tue, 11 Jan 2005 13:23:42 -0700
Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv28010
Modified Files:
sys_unix.c
Log Message:
SYS_Random(): improve performances
Thanks to Philipp Marek for the patch
--- /cvsroot/pcsclite/PCSC/src/sys_unix.c 2004/08/06 12:12:20 1.12
+++ /cvsroot/pcsclite/PCSC/src/sys_unix.c 2005/01/11 20:23:42 1.13
@@ -6,7 +6,7 @@
* Copyright (C) 1999
* David Corcoran <corcoran@linuxnet.com>
*
- * $Id: sys_unix.c,v 1.12 2004/08/06 12:12:20 rousseau Exp $
+ * $Id: sys_unix.c,v 1.13 2005/01/11 20:23:42 rousseau Exp $
*/
#include "config.h"
@@ -293,16 +293,16 @@
int SYS_Random(int iSeed, float fStart, float fEnd)
{
-
+ static int iInitialized = 0;
int iRandNum = 0;
- if (iSeed != 0)
+ if (0 == iInitialized)
{
- srand(iSeed);
+ srand(SYS_GetSeed());
+ iInitialized = 1;
}
iRandNum = 1 + (int) (fEnd * rand() / (RAND_MAX + fStart));
- srand(iRandNum);
return iRandNum;
}