mirror of
https://github.com/sqlite/sqlite.git
synced 2025-08-05 15:55:57 +03:00
Extend the refactoring into extensions. Clean up stray newlines.
FossilOrigin-Name: 7a876209a678a34c198b54ceef9e3c041f128a14dc73357f6a57cadadaa6cf7b
This commit is contained in:
12
src/main.c
12
src/main.c
@@ -201,7 +201,7 @@ char *sqlite3_data_directory = 0;
|
||||
** without blocking.
|
||||
*/
|
||||
int sqlite3_initialize(void){
|
||||
MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
|
||||
MUTEX_LOGIC( sqlite3_mutex *pMainMtx; ) /* The main static mutex */
|
||||
int rc; /* Result code */
|
||||
#ifdef SQLITE_EXTRA_INIT
|
||||
int bRunExtraInit = 0; /* Extra initialization needed */
|
||||
@@ -246,8 +246,8 @@ int sqlite3_initialize(void){
|
||||
** malloc subsystem - this implies that the allocation of a static
|
||||
** mutex must not require support from the malloc subsystem.
|
||||
*/
|
||||
MUTEX_LOGIC( pMaster = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MAIN); )
|
||||
sqlite3_mutex_enter(pMaster);
|
||||
MUTEX_LOGIC( pMainMtx = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MAIN); )
|
||||
sqlite3_mutex_enter(pMainMtx);
|
||||
sqlite3GlobalConfig.isMutexInit = 1;
|
||||
if( !sqlite3GlobalConfig.isMallocInit ){
|
||||
rc = sqlite3MallocInit();
|
||||
@@ -265,7 +265,7 @@ int sqlite3_initialize(void){
|
||||
if( rc==SQLITE_OK ){
|
||||
sqlite3GlobalConfig.nRefInitMutex++;
|
||||
}
|
||||
sqlite3_mutex_leave(pMaster);
|
||||
sqlite3_mutex_leave(pMainMtx);
|
||||
|
||||
/* If rc is not SQLITE_OK at this point, then either the malloc
|
||||
** subsystem could not be initialized or the system failed to allocate
|
||||
@@ -326,14 +326,14 @@ int sqlite3_initialize(void){
|
||||
/* Go back under the static mutex and clean up the recursive
|
||||
** mutex to prevent a resource leak.
|
||||
*/
|
||||
sqlite3_mutex_enter(pMaster);
|
||||
sqlite3_mutex_enter(pMainMtx);
|
||||
sqlite3GlobalConfig.nRefInitMutex--;
|
||||
if( sqlite3GlobalConfig.nRefInitMutex<=0 ){
|
||||
assert( sqlite3GlobalConfig.nRefInitMutex==0 );
|
||||
sqlite3_mutex_free(sqlite3GlobalConfig.pInitMutex);
|
||||
sqlite3GlobalConfig.pInitMutex = 0;
|
||||
}
|
||||
sqlite3_mutex_leave(pMaster);
|
||||
sqlite3_mutex_leave(pMainMtx);
|
||||
|
||||
/* The following is just a sanity check to make sure SQLite has
|
||||
** been compiled correctly. It is important to run this code, but
|
||||
|
Reference in New Issue
Block a user