diff options
author | drh <drh@noemail.net> | 2007-08-21 13:51:23 +0000 |
---|---|---|
committer | drh <drh@noemail.net> | 2007-08-21 13:51:23 +0000 |
commit | 51fc347a2ef312dad4bff734d9c6e316d4e6a9f6 (patch) | |
tree | 30306e344f8c6368a7dc2435f3621705313c96aa /src/random.c | |
parent | 46abae817e4ae160048a8604e096aa1ca5c7a060 (diff) | |
download | sqlite-51fc347a2ef312dad4bff734d9c6e316d4e6a9f6.tar.gz sqlite-51fc347a2ef312dad4bff734d9c6e316d4e6a9f6.zip |
Remove the obsolete static mutexes. Use only the lastest static mutex code. (CVS 4259)
FossilOrigin-Name: 6225cd461cdd2132eeb480aa4deb8986b7f63c15
Diffstat (limited to 'src/random.c')
-rw-r--r-- | src/random.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/random.c b/src/random.c index 6443a01e0..19b284f94 100644 --- a/src/random.c +++ b/src/random.c @@ -15,7 +15,7 @@ ** Random numbers are used by some of the database backends in order ** to generate random integer keys for tables or random filenames. ** -** $Id: random.c,v 1.19 2007/08/21 10:44:16 drh Exp $ +** $Id: random.c,v 1.20 2007/08/21 13:51:23 drh Exp $ */ #include "sqliteInt.h" @@ -91,9 +91,13 @@ static int randomByte(void){ */ void sqlite3Randomness(int N, void *pBuf){ unsigned char *zBuf = pBuf; - sqlite3_mutex_enter(sqlite3_mutex_alloc(SQLITE_MUTEX_PRNG)); + static sqlite3_mutex *mutex = 0; + if( mutex==0 ){ + mutex = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_PRNG); + } + sqlite3_mutex_enter(mutex); while( N-- ){ *(zBuf++) = randomByte(); } - sqlite3_mutex_leave(sqlite3_mutex_alloc(SQLITE_MUTEX_PRNG)); + sqlite3_mutex_leave(mutex); } |