mem5 16231 sqlite3/libsqlite/sqlite3.c } mem5; mem5 16236 sqlite3/libsqlite/sqlite3.c #define mem5 GLOBAL(struct Mem5Global, mem5) mem5 16242 sqlite3/libsqlite/sqlite3.c #define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom])) mem5 16250 sqlite3/libsqlite/sqlite3.c assert( i>=0 && i<mem5.nBlock ); mem5 16252 sqlite3/libsqlite/sqlite3.c assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize ); mem5 16257 sqlite3/libsqlite/sqlite3.c mem5.aiFreelist[iLogsize] = next; mem5 16272 sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem5.mutex) ); mem5 16273 sqlite3/libsqlite/sqlite3.c assert( i>=0 && i<mem5.nBlock ); mem5 16275 sqlite3/libsqlite/sqlite3.c assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize ); mem5 16277 sqlite3/libsqlite/sqlite3.c x = MEM5LINK(i)->next = mem5.aiFreelist[iLogsize]; mem5 16280 sqlite3/libsqlite/sqlite3.c assert( x<mem5.nBlock ); mem5 16283 sqlite3/libsqlite/sqlite3.c mem5.aiFreelist[iLogsize] = i; mem5 16292 sqlite3/libsqlite/sqlite3.c sqlite3_mutex_enter(mem5.mutex); mem5 16295 sqlite3/libsqlite/sqlite3.c sqlite3_mutex_leave(mem5.mutex); mem5 16306 sqlite3/libsqlite/sqlite3.c int i = ((u8 *)p-mem5.zPool)/mem5.szAtom; mem5 16307 sqlite3/libsqlite/sqlite3.c assert( i>=0 && i<mem5.nBlock ); mem5 16308 sqlite3/libsqlite/sqlite3.c iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE)); mem5 16322 sqlite3/libsqlite/sqlite3.c i = iFirst = mem5.aiFreelist[iLogsize]; mem5 16353 sqlite3/libsqlite/sqlite3.c if( (u32)nByte>mem5.maxRequest ){ mem5 16354 sqlite3/libsqlite/sqlite3.c mem5.maxRequest = nByte; mem5 16365 sqlite3/libsqlite/sqlite3.c for(iFullSz=mem5.szAtom, iLogsize=0; iFullSz<nByte; iFullSz *= 2, iLogsize++){} mem5 16371 sqlite3/libsqlite/sqlite3.c for(iBin=iLogsize; mem5.aiFreelist[iBin]<0 && iBin<=LOGMAX; iBin++){} mem5 16383 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[i+newSize] = CTRL_FREE | iBin; mem5 16386 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[i] = iLogsize; mem5 16389 sqlite3/libsqlite/sqlite3.c mem5.nAlloc++; mem5 16390 sqlite3/libsqlite/sqlite3.c mem5.totalAlloc += iFullSz; mem5 16391 sqlite3/libsqlite/sqlite3.c mem5.totalExcess += iFullSz - nByte; mem5 16392 sqlite3/libsqlite/sqlite3.c mem5.currentCount++; mem5 16393 sqlite3/libsqlite/sqlite3.c mem5.currentOut += iFullSz; mem5 16394 sqlite3/libsqlite/sqlite3.c if( mem5.maxCount<mem5.currentCount ) mem5.maxCount = mem5.currentCount; mem5 16395 sqlite3/libsqlite/sqlite3.c if( mem5.maxOut<mem5.currentOut ) mem5.maxOut = mem5.currentOut; mem5 16398 sqlite3/libsqlite/sqlite3.c return (void*)&mem5.zPool[i*mem5.szAtom]; mem5 16411 sqlite3/libsqlite/sqlite3.c iBlock = ((u8 *)pOld-mem5.zPool)/mem5.szAtom; mem5 16414 sqlite3/libsqlite/sqlite3.c assert( iBlock>=0 && iBlock<mem5.nBlock ); mem5 16415 sqlite3/libsqlite/sqlite3.c assert( ((u8 *)pOld-mem5.zPool)%mem5.szAtom==0 ); mem5 16416 sqlite3/libsqlite/sqlite3.c assert( (mem5.aCtrl[iBlock] & CTRL_FREE)==0 ); mem5 16418 sqlite3/libsqlite/sqlite3.c iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE; mem5 16420 sqlite3/libsqlite/sqlite3.c assert( iBlock+size-1<(u32)mem5.nBlock ); mem5 16422 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock] |= CTRL_FREE; mem5 16423 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock+size-1] |= CTRL_FREE; mem5 16424 sqlite3/libsqlite/sqlite3.c assert( mem5.currentCount>0 ); mem5 16425 sqlite3/libsqlite/sqlite3.c assert( mem5.currentOut>=(size*mem5.szAtom) ); mem5 16426 sqlite3/libsqlite/sqlite3.c mem5.currentCount--; mem5 16427 sqlite3/libsqlite/sqlite3.c mem5.currentOut -= size*mem5.szAtom; mem5 16428 sqlite3/libsqlite/sqlite3.c assert( mem5.currentOut>0 || mem5.currentCount==0 ); mem5 16429 sqlite3/libsqlite/sqlite3.c assert( mem5.currentCount>0 || mem5.currentOut==0 ); mem5 16431 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize; mem5 16440 sqlite3/libsqlite/sqlite3.c if( (iBuddy+(1<<iLogsize))>mem5.nBlock ) break; mem5 16441 sqlite3/libsqlite/sqlite3.c if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break; mem5 16445 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBuddy] = CTRL_FREE | iLogsize; mem5 16446 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock] = 0; mem5 16449 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize; mem5 16450 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBuddy] = 0; mem5 16530 sqlite3/libsqlite/sqlite3.c for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2); mem5 16566 sqlite3/libsqlite/sqlite3.c mem5.mutex = 0; mem5 16579 sqlite3/libsqlite/sqlite3.c mem5.szAtom = (1<<nMinLog); mem5 16580 sqlite3/libsqlite/sqlite3.c while( (int)sizeof(Mem5Link)>mem5.szAtom ){ mem5 16581 sqlite3/libsqlite/sqlite3.c mem5.szAtom = mem5.szAtom << 1; mem5 16584 sqlite3/libsqlite/sqlite3.c mem5.nBlock = (nByte / (mem5.szAtom+sizeof(u8))); mem5 16585 sqlite3/libsqlite/sqlite3.c mem5.zPool = zByte; mem5 16586 sqlite3/libsqlite/sqlite3.c mem5.aCtrl = (u8 *)&mem5.zPool[mem5.nBlock*mem5.szAtom]; mem5 16589 sqlite3/libsqlite/sqlite3.c mem5.aiFreelist[ii] = -1; mem5 16595 sqlite3/libsqlite/sqlite3.c if( (iOffset+nAlloc)<=mem5.nBlock ){ mem5 16596 sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iOffset] = ii | CTRL_FREE; mem5 16600 sqlite3/libsqlite/sqlite3.c assert((iOffset+nAlloc)>mem5.nBlock); mem5 16605 sqlite3/libsqlite/sqlite3.c mem5.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); mem5 16616 sqlite3/libsqlite/sqlite3.c mem5.mutex = 0; mem5 16641 sqlite3/libsqlite/sqlite3.c nMinLog = memsys5Log(mem5.szAtom); mem5 16643 sqlite3/libsqlite/sqlite3.c for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){} mem5 16644 sqlite3/libsqlite/sqlite3.c fprintf(out, "freelist items of size %d: %d\n", mem5.szAtom << i, n); mem5 16646 sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.nAlloc = %llu\n", mem5.nAlloc); mem5 16647 sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.totalAlloc = %llu\n", mem5.totalAlloc); mem5 16648 sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.totalExcess = %llu\n", mem5.totalExcess); mem5 16649 sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.currentOut = %u\n", mem5.currentOut); mem5 16650 sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.currentCount = %u\n", mem5.currentCount); mem5 16651 sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.maxOut = %u\n", mem5.maxOut); mem5 16652 sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.maxCount = %u\n", mem5.maxCount); mem5 16653 sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.maxRequest = %u\n", mem5.maxRequest);