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