better random seed

This commit is contained in:
tater 2018-08-24 03:20:33 -04:00
parent e642b5ed76
commit 0225b8881d

View File

@ -24,12 +24,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <sysexits.h> #include <sysexits.h>
#include <time.h>
#include <unistd.h> #include <unistd.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <sys/queue.h> #include <sys/queue.h>
#include <sys/stat.h> #include <sys/stat.h>
#include <sys/time.h>
#include <sys/types.h> #include <sys/types.h>
#ifdef DEBUG #ifdef DEBUG
@ -153,6 +153,8 @@ main(int argc, char *argv[])
opt.random = false; opt.random = false;
char *fontfile = NULL; char *fontfile = NULL;
struct timeval tv;
DIR *d; DIR *d;
struct dirent *dir; struct dirent *dir;
SLIST_HEAD(, dirname_s) head = SLIST_HEAD_INITIALIZER(dirname_s); SLIST_HEAD(, dirname_s) head = SLIST_HEAD_INITIALIZER(dirname_s);
@ -251,7 +253,9 @@ main(int argc, char *argv[])
} }
closedir(d); closedir(d);
srand(time(NULL)); gettimeofday(&tv, NULL);
srand(tv.tv_usec);
r = dll ? rand() % dll : 0; r = dll ? rand() % dll : 0;
dp = SLIST_FIRST(&head); dp = SLIST_FIRST(&head);