Example #1
0
 /*
 ** Deinitialize the memory allocation subsystem.
 */
 static void sqlite3MallocEnd()
 {
   if ( sqlite3GlobalConfig.m.xShutdown != null )
   {
     sqlite3GlobalConfig.m.xShutdown( sqlite3GlobalConfig.m.pAppData );
   }
   mem0 = new Mem0Global();//memset(&mem0, 0, sizeof(mem0));
 }
Example #2
0
    //#define mem0 GLOBAL(struct Mem0Global, mem0)


    /*
    ** Initialize the memory allocation subsystem.
    */
    static int sqlite3MallocInit()
    {
      if ( sqlite3GlobalConfig.m.xMalloc == null )
      {
        sqlite3MemSetDefault();
      }
      mem0 = new Mem0Global(); //memset(&mem0, 0, sizeof(mem0));
      if ( sqlite3GlobalConfig.bCoreMutex )
      {
        mem0.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MEM );
      }
      if ( sqlite3GlobalConfig.pScratch != null && sqlite3GlobalConfig.szScratch >= 100
      && sqlite3GlobalConfig.nScratch >= 0 )
      {
        Debugger.Break(); // TODO --

        //  int i;
        //  sqlite3GlobalConfig.szScratch = ROUNDDOWN8(sqlite3GlobalConfig.szScratch-4);
        //  mem0.aScratchFree = (u32*)&((char*) sqlite3GlobalConfig.pScratch)
        //                [ sqlite3GlobalConfig.szScratch* sqlite3GlobalConfig.nScratch];
        //  for(i=0; i< sqlite3GlobalConfig.nScratch; i++){ mem0.aScratchFree[i] = i; }
        //  mem0.nScratchFree =  sqlite3GlobalConfig.nScratch;
      }
      else
      {
        sqlite3GlobalConfig.pScratch = null;
        sqlite3GlobalConfig.szScratch = 0;
      }
      if ( sqlite3GlobalConfig.pPage != null && sqlite3GlobalConfig.szPage >= 512
      && sqlite3GlobalConfig.nPage >= 1 )
      {
        int i;
        int overhead;
        int sz = ROUNDDOWN8( sqlite3GlobalConfig.szPage );
        int n = sqlite3GlobalConfig.nPage;
        overhead = ( 4 * n + sz - 1 ) / sz;
        sqlite3GlobalConfig.nPage -= overhead;
        mem0.aPageFree = new int[sqlite3GlobalConfig.szPage * sqlite3GlobalConfig.nPage];
        //  mem0.aPageFree = (u32*)&((char*) sqlite3GlobalConfig.pPage)
        //                [ sqlite3GlobalConfig.szPage* sqlite3GlobalConfig.nPage];
        for ( i = 0 ; i < sqlite3GlobalConfig.nPage ; i++ ) { mem0.aPageFree[i] = i; }
        mem0.nPageFree = sqlite3GlobalConfig.nPage;
      }
      else
      {
        sqlite3GlobalConfig.pPage = null;
        sqlite3GlobalConfig.szPage = 0;
      }
      return sqlite3GlobalConfig.m.xInit( sqlite3GlobalConfig.m.pAppData );
    }
Example #3
0
 /*
 ** Initialize the memory allocation subsystem.
 */
 static int sqlite3MallocInit()
 {
   if ( sqlite3GlobalConfig.m.xMalloc == null )
   {
     sqlite3MemSetDefault();
   }
   mem0 = new Mem0Global(0, 0, null, 0, null, null, 1, 1, 8, 8);  //memset(&mem0, 0, sizeof(mem0));
   if ( sqlite3GlobalConfig.bCoreMutex )
   {
     mem0.mutex = sqlite3MutexAlloc( SQLITE_MUTEX_STATIC_MEM );
   }
   if ( sqlite3GlobalConfig.pScratch != null && sqlite3GlobalConfig.szScratch >= 100
       && sqlite3GlobalConfig.nScratch >= 0 )
   {
     int i;
     sqlite3GlobalConfig.szScratch = ROUNDDOWN8( sqlite3GlobalConfig.szScratch - 4 );
     //mem0.aScratchFree = (u32*)&((char*)sqlite3GlobalConfig.pScratch)
     //  [sqlite3GlobalConfig.szScratch*sqlite3GlobalConfig.nScratch];
     //for(i=0; i<sqlite3GlobalConfig.nScratch; i++){ mem0.aScratchFree[i] = i; }
     //mem0.nScratchFree = sqlite3GlobalConfig.nScratch;
   }
   else
   {
     sqlite3GlobalConfig.pScratch = null;
     sqlite3GlobalConfig.szScratch = 0;
   }
   if ( sqlite3GlobalConfig.pPage != null && sqlite3GlobalConfig.szPage >= 512
       && sqlite3GlobalConfig.nPage >= 1 )
   {
     int i;
     int overhead;
     int sz = ROUNDDOWN8( sqlite3GlobalConfig.szPage );
     int n = sqlite3GlobalConfig.nPage;
     overhead = ( 4 * n + sz - 1 ) / sz;
     sqlite3GlobalConfig.nPage -= overhead;
     //mem0.aPageFree = (u32*)&((char*)sqlite3GlobalConfig.pPage)
     //[sqlite3GlobalConfig.szPage*sqlite3GlobalConfig.nPage];
     //for(i=0; i<sqlite3GlobalConfig.nPage; i++){ mem0.aPageFree[i] = i; }
     //mem0.nPageFree = sqlite3GlobalConfig.nPage;
   }
   else
   {
     sqlite3GlobalConfig.pPage = null;
     sqlite3GlobalConfig.nPage = 0;
   }
   return sqlite3GlobalConfig.m.xInit( sqlite3GlobalConfig.m.pAppData );
 }