| OLD | NEW |
| 1 /* | 1 /* |
| 2 ** 2001 September 15 | 2 ** 2001 September 15 |
| 3 ** | 3 ** |
| 4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
| 5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
| 6 ** | 6 ** |
| 7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
| 8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
| 9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
| 10 ** | 10 ** |
| (...skipping 30 matching lines...) Expand all Loading... |
| 41 ** to the "sqlite3Prng" state vector declared above. | 41 ** to the "sqlite3Prng" state vector declared above. |
| 42 */ | 42 */ |
| 43 #ifdef SQLITE_OMIT_WSD | 43 #ifdef SQLITE_OMIT_WSD |
| 44 struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng); | 44 struct sqlite3PrngType *p = &GLOBAL(struct sqlite3PrngType, sqlite3Prng); |
| 45 # define wsdPrng p[0] | 45 # define wsdPrng p[0] |
| 46 #else | 46 #else |
| 47 # define wsdPrng sqlite3Prng | 47 # define wsdPrng sqlite3Prng |
| 48 #endif | 48 #endif |
| 49 | 49 |
| 50 #if SQLITE_THREADSAFE | 50 #if SQLITE_THREADSAFE |
| 51 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); | 51 sqlite3_mutex *mutex; |
| 52 sqlite3_mutex_enter(mutex); | |
| 53 #endif | 52 #endif |
| 54 | 53 |
| 55 if( N<=0 ){ | 54 #ifndef SQLITE_OMIT_AUTOINIT |
| 55 if( sqlite3_initialize() ) return; |
| 56 #endif |
| 57 |
| 58 #if SQLITE_THREADSAFE |
| 59 mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_PRNG); |
| 60 #endif |
| 61 |
| 62 sqlite3_mutex_enter(mutex); |
| 63 if( N<=0 || pBuf==0 ){ |
| 56 wsdPrng.isInit = 0; | 64 wsdPrng.isInit = 0; |
| 57 sqlite3_mutex_leave(mutex); | 65 sqlite3_mutex_leave(mutex); |
| 58 return; | 66 return; |
| 59 } | 67 } |
| 60 | 68 |
| 61 /* Initialize the state of the random number generator once, | 69 /* Initialize the state of the random number generator once, |
| 62 ** the first time this routine is called. The seed value does | 70 ** the first time this routine is called. The seed value does |
| 63 ** not need to contain a lot of randomness since we are not | 71 ** not need to contain a lot of randomness since we are not |
| 64 ** trying to do secure encryption or anything like that... | 72 ** trying to do secure encryption or anything like that... |
| 65 ** | 73 ** |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 ); | 125 ); |
| 118 } | 126 } |
| 119 void sqlite3PrngRestoreState(void){ | 127 void sqlite3PrngRestoreState(void){ |
| 120 memcpy( | 128 memcpy( |
| 121 &GLOBAL(struct sqlite3PrngType, sqlite3Prng), | 129 &GLOBAL(struct sqlite3PrngType, sqlite3Prng), |
| 122 &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), | 130 &GLOBAL(struct sqlite3PrngType, sqlite3SavedPrng), |
| 123 sizeof(sqlite3Prng) | 131 sizeof(sqlite3Prng) |
| 124 ); | 132 ); |
| 125 } | 133 } |
| 126 #endif /* SQLITE_OMIT_BUILTIN_TEST */ | 134 #endif /* SQLITE_OMIT_BUILTIN_TEST */ |
| OLD | NEW |