예제 #1
0
 private static void pcache1Free(ref PgHdr p)
 {
     if (p == null)
         return;
     if (p.CacheAllocated)
     {
         var pSlot = new PgFreeslot();
         MutexEx.sqlite3_mutex_enter(pcache1.mutex);
         StatusEx.sqlite3StatusAdd(StatusEx.STATUS.PAGECACHE_USED, -1);
         pSlot._PgHdr = p;
         pSlot.pNext = pcache1.pFree;
         pcache1.pFree = pSlot;
         pcache1.nFreeSlot++;
         pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve;
         Debug.Assert(pcache1.nFreeSlot <= pcache1.nSlot);
         MutexEx.sqlite3_mutex_leave(pcache1.mutex);
     }
     else
     {
         Debug.Assert(SysEx.sqlite3MemdebugHasType(p, SysEx.MEMTYPE.PCACHE));
         SysEx.sqlite3MemdebugSetType(p, SysEx.MEMTYPE.HEAP);
         var iSize = MallocEx.sqlite3MallocSize(p.Data);
         MutexEx.sqlite3_mutex_enter(pcache1.mutex);
         StatusEx.sqlite3StatusAdd(StatusEx.STATUS.PAGECACHE_OVERFLOW, -iSize);
         MutexEx.sqlite3_mutex_leave(pcache1.mutex);
         MallocEx.sqlite3_free(ref p.Data);
     }
 }
예제 #2
0
 private static void pcache1Free(ref PgHdr p)
 {
     if (p == null)
     {
         return;
     }
     if (p.CacheAllocated)
     {
         var pSlot = new PgFreeslot();
         MutexEx.Enter(pcache1.mutex);
         StatusEx.sqlite3StatusAdd(StatusEx.STATUS.PAGECACHE_USED, -1);
         pSlot._PgHdr  = p;
         pSlot.pNext   = pcache1.pFree;
         pcache1.pFree = pSlot;
         pcache1.nFreeSlot++;
         pcache1.bUnderPressure = pcache1.nFreeSlot < pcache1.nReserve;
         Debug.Assert(pcache1.nFreeSlot <= pcache1.nSlot);
         MutexEx.Leave(pcache1.mutex);
     }
     else
     {
         Debug.Assert(SysEx.sqlite3MemdebugHasType(p, SysEx.MEMTYPE.PCACHE));
         SysEx.sqlite3MemdebugSetType(p, SysEx.MEMTYPE.HEAP);
         var iSize = MallocEx.sqlite3MallocSize(p.Data);
         MutexEx.Enter(pcache1.mutex);
         StatusEx.sqlite3StatusAdd(StatusEx.STATUS.PAGECACHE_OVERFLOW, -iSize);
         MutexEx.Leave(pcache1.mutex);
         MallocEx.sqlite3_free(ref p.Data);
     }
 }
예제 #3
0
 private static void sqlite3PCacheBufferSetup(object pBuf, int sz, int n)
 {
     if (pcache1 != null)
     {
         sz                     = SysEx.ROUNDDOWN8(sz);
         pcache1.szSlot         = sz;
         pcache1.nSlot          = pcache1.nFreeSlot = n;
         pcache1.nReserve       = n > 90 ? 10 : (n / 10 + 1);
         pcache1.pStart         = null;
         pcache1.pEnd           = null;
         pcache1.pFree          = null;
         pcache1.bUnderPressure = false;
         PgFreeslot p;
         while (n-- > 0)
         {
             p             = new PgFreeslot();
             p._PgHdr      = new PgHdr();
             p.pNext       = pcache1.pFree;
             pcache1.pFree = p;
         }
         pcache1.pEnd = pBuf;
     }
 }
예제 #4
0
 private static void sqlite3PCacheBufferSetup(object pBuf, int sz, int n)
 {
     if (pcache1 != null)
     {
         sz = SysEx.ROUNDDOWN8(sz);
         pcache1.szSlot = sz;
         pcache1.nSlot = pcache1.nFreeSlot = n;
         pcache1.nReserve = n > 90 ? 10 : (n / 10 + 1);
         pcache1.pStart = null;
         pcache1.pEnd = null;
         pcache1.pFree = null;
         pcache1.bUnderPressure = false;
         PgFreeslot p;
         while (n-- > 0)
         {
             p = new PgFreeslot();
             p._PgHdr = new PgHdr();
             p.pNext = pcache1.pFree;
             pcache1.pFree = p;
         }
         pcache1.pEnd = pBuf;
     }
 }