cvs: /php4/ext/standard uniqid.c
| From: | Sascha Schumann | Date: | Sat, 21 Aug 1999 17:22:08 +0000 |
| Subject: | cvs: /php4/ext/standard uniqid.c | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-3626@lists.php.net to get a copy of this message | ||
sas Sat Aug 21 13:22:08 1999 EDT
Modified files:
/php4/ext/standard uniqid.c
Log:
get rid of that usleep() and add some entropy using the combined lcg
Index: php4/ext/standard/uniqid.c
diff -u php4/ext/standard/uniqid.c:1.6 php4/ext/standard/uniqid.c:1.7
--- php4/ext/standard/uniqid.c:1.6 Mon Aug 2 15:16:51 1999
+++ php4/ext/standard/uniqid.c Sat Aug 21 13:22:08 1999
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: uniqid.c,v 1.6 1999/08/02 19:16:51 zeev Exp $ */
+/* $Id: uniqid.c,v 1.7 1999/08/21 17:22:08 sas Exp $ */
#include "php.h"
@@ -35,6 +35,7 @@
#include <sys/time.h>
#endif
+#include "../lcg/php_lcg.h"
#include "uniqid.h"
/* {{{ proto string uniqid(string prefix)
@@ -43,7 +44,7 @@
{
#ifdef HAVE_GETTIMEOFDAY
pval *prefix;
- char uniqid[128];
+ char uniqid[138];
int sec, usec;
struct timeval tv;
@@ -57,10 +58,6 @@
php_error(E_WARNING, "The prefix to uniqid should not be more than 114 characters.");
return;
}
- /* dont need this on windows so lets not do it*/
-#if HAVE_USLEEP && !(WIN32|WINNT)
- usleep(1);
-#endif
gettimeofday((struct timeval *) &tv, (struct timezone *) NULL);
sec = (int) tv.tv_sec;
usec = (int) (tv.tv_usec % 1000000);
@@ -68,7 +65,7 @@
/* The max value usec can have is 0xF423F, so we use only five hex
* digits for usecs:
*/
- sprintf(uniqid, "%s%08x%05x", prefix->value.str.val, sec, usec);
+ sprintf(uniqid, "%s%08x%05x%.8f", prefix->value.str.val, sec, usec,
php_combined_lcg() * 10);
RETURN_STRING(uniqid,1);
#endif