|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r61180 - in branches/release: boost/uuid libs/uuid
From: atompkins_at_[hidden]
Date: 2010-04-10 11:13:41
Author: atompkins
Date: 2010-04-10 11:13:40 EDT (Sat, 10 Apr 2010)
New Revision: 61180
URL: http://svn.boost.org/trac/boost/changeset/61180
Log:
Added notes to documentation about using Valgrind
Added some comments to seed_rng.hpp
Text files modified:
branches/release/boost/uuid/seed_rng.hpp | 4 ++++
branches/release/libs/uuid/uuid.html | 13 +++++++++++++
2 files changed, 17 insertions(+), 0 deletions(-)
Modified: branches/release/boost/uuid/seed_rng.hpp
==============================================================================
--- branches/release/boost/uuid/seed_rng.hpp (original)
+++ branches/release/boost/uuid/seed_rng.hpp 2010-04-10 11:13:40 EDT (Sat, 10 Apr 2010)
@@ -75,6 +75,7 @@
//BOOST_STATIC_CONSTANT(unsigned int, max_value = UINT_MAX);
public:
+ // note: rd_ intentionally left uninitialized
seed_rng()
: rd_index_(5)
, random_(std::fopen( "/dev/urandom", "rb" ))
@@ -111,6 +112,7 @@
private:
static unsigned int * sha1_random_digest_state_()
{
+ // intentionally left uninitialized
static unsigned int state[ 5 ];
return state;
}
@@ -143,6 +145,7 @@
}
{
+ // intentionally left uninitialized
unsigned char buffer[ 20 ];
if(random_)
@@ -156,6 +159,7 @@
}
{
+ // *p is intentionally left uninitialized
unsigned int * p = new unsigned int;
sha.process_bytes( (unsigned char const*)p, sizeof( *p ) );
Modified: branches/release/libs/uuid/uuid.html
==============================================================================
--- branches/release/libs/uuid/uuid.html (original)
+++ branches/release/libs/uuid/uuid.html 2010-04-10 11:13:40 EDT (Sat, 10 Apr 2010)
@@ -587,6 +587,19 @@
values including <tt>std::time(0)</tt>, <tt>std::clock()</tt>, uninitialized
data, value return from <tt>new unsigned int</tt>, etc..
+<p>Using Valgrind produces a number of false
+positives with the default constructor of <tt>boost::uuids::basic_random_generator</tt>.
+One solution is to suppress the errors as described in
+Valgrind's documentation.
+Another solution is to use a different constructor of <tt>boost::uuids::basic_random_generator</tt>
+and explicitly pass in a random number generator.
+<pre>
+boost::mt19937 ran;
+ran.seed(time(NULL)); // one should likely seed in a better way
+boost::uuids::basic_random_generator<boost::mt19937> gen(&ran);
+boost::uuids::uuid u = gen();
+</pre>
+
<p>The <tt>boost::uuids::name_generator</tt> class uses the SHA-1 hash function to
compute the <b>uuid</b>.
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk