Esempio n. 1
0
/*
** Initialize the mutex system.
*/
        static int sqlite3MutexInit()
        {
            int rc = SQLITE_OK;

            if (null == sqlite3GlobalConfig.mutex.xMutexAlloc)
            {
                /* If the xMutexAlloc method has not been set, then the user did not
                ** install a mutex implementation via sqlite3_config() prior to
                ** sqlite3_initialize() being called. This block copies pointers to
                ** the default implementation into the sqlite3GlobalConfig structure.
                */
                sqlite3_mutex_methods pFrom;
                sqlite3_mutex_methods pTo = sqlite3GlobalConfig.mutex;

                if (sqlite3GlobalConfig.bCoreMutex)
                {
                    pFrom = sqlite3DefaultMutex();
                }
                else
                {
                    pFrom = sqlite3NoopMutex();
                }
                //memcpy(pTo, pFrom, offsetof(sqlite3_mutex_methods, xMutexAlloc));
                //memcpy(pTo.xMutexFree, pFrom.xMutexFree,
                //	   sizeof(*pTo) - offsetof(sqlite3_mutex_methods, xMutexFree));
                pTo.Copy(pFrom);
            }
            rc = sqlite3GlobalConfig.mutex.xMutexInit();

#if SQLITE_DEBUG
            mutexIsInit = 1; //GLOBAL(int, mutexIsInit) = 1;
#endif

            return(rc);
        }