- Fixed bug whereby the UUID generated by the custom generator was not terminated.

- Fixed bug whereby random numbers were used by the custom UUID generator, but srandom/srand was not called first.
This commit is contained in:
Paul Beckingham 2008-06-04 21:00:23 -04:00
parent f3de5c0711
commit 08f4ead97e
5 changed files with 20 additions and 6 deletions

View file

@ -182,14 +182,18 @@ const std::string uuid ()
static char randomHexDigit ()
{
static char digits[] = "0123456789abcdef";
#ifdef HAVE_RANDOM
return digits[random () % 16];
#else
return digits[rand () % 16];
#endif
}
////////////////////////////////////////////////////////////////////////////////
const std::string uuid ()
{
// xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
char id [37];
char id [48] = {0};
id[0] = randomHexDigit ();
id[1] = randomHexDigit ();
id[2] = randomHexDigit ();