mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-08-22 08:58:54 +02:00
Improve chance to generate unique names with less effort a bit.
2000-11-11 Tor Lillqvist <tml@iki.fi> * gfileutils.c (g_mkstemp): Improve chance to generate unique names with less effort a bit. * gfileutils.h: Add g_file_open_tmp() declaration. * testglib.c: Include <io.h> on Win32. * makefile.mingw.in: Correct the way to invoke sub-makes. 2000-11-11 Tor Lillqvist <tml@iki.fi> * gtypemodule.c: Include stdlib.h for exit(). * makefile.{mingw,msc}.in (gobject_OBJECTS): Add gtypemodule. * gobject.def: Add new functions.
This commit is contained in:
committed by
Tor Lillqvist
parent
40cfd305c2
commit
4f76917c6a
@@ -538,6 +538,7 @@ g_mkstemp (char *tmpl)
|
||||
static const int NLETTERS = sizeof (letters) - 1;
|
||||
glong value;
|
||||
GTimeVal tv;
|
||||
static int counter = 0;
|
||||
|
||||
len = strlen (tmpl);
|
||||
if (len < 6 || strcmp (&tmpl[len - 6], "XXXXXX"))
|
||||
@@ -548,7 +549,7 @@ g_mkstemp (char *tmpl)
|
||||
|
||||
/* Get some more or less random data. */
|
||||
g_get_current_time (&tv);
|
||||
value = tv.tv_usec ^ tv.tv_sec;
|
||||
value = (tv.tv_usec ^ tv.tv_sec) + counter++;
|
||||
|
||||
for (count = 0; count < 100; value += 7777, ++count)
|
||||
{
|
||||
|
Reference in New Issue
Block a user