[Pcsclite-cvs-commit] CVS PCSC/src

CVS User rousseau ludovic.rousseau@free.fr
Tue, 11 Jan 2005 13:44:54 -0700


Update of /cvsroot/pcsclite/PCSC/src
In directory haydn:/tmp/cvs-serv16255

Modified Files:
	sys_unix.c 
Log Message:
convert SYS_Random() into SYS_RandomInt() to improve performances.

Thanks to Philipp Marek for the patch


--- /cvsroot/pcsclite/PCSC/src/sys_unix.c	2005/01/11 20:23:42	1.13
+++ /cvsroot/pcsclite/PCSC/src/sys_unix.c	2005/01/11 20:44:54	1.14
@@ -6,7 +6,7 @@
  * Copyright (C) 1999
  *  David Corcoran <corcoran@linuxnet.com>
  *
- * $Id: sys_unix.c,v 1.13 2005/01/11 20:23:42 rousseau Exp $
+ * $Id: sys_unix.c,v 1.14 2005/01/11 20:44:54 rousseau Exp $
  */
 
 #include "config.h"
@@ -291,7 +291,7 @@
 	return fstat(iFd, &sStatus);
 }
 
-int SYS_Random(int iSeed, float fStart, float fEnd)
+int SYS_RandomInt(int fStart, int fEnd)
 {
 	static int iInitialized = 0;
 	int iRandNum = 0;
@@ -302,7 +302,7 @@
 		iInitialized = 1;
 	}
 
-	iRandNum = 1 + (int) (fEnd * rand() / (RAND_MAX + fStart));
+	iRandNum = (int)((float)rand()/RAND_MAX * (fEnd - fStart)) + fStart;
 
 	return iRandNum;
 }