mem5 18657 ext/sqlite3/libsqlite/sqlite3.c } mem5; mem5 18662 ext/sqlite3/libsqlite/sqlite3.c #define mem5 GLOBAL(struct Mem5Global, mem5) mem5 18668 ext/sqlite3/libsqlite/sqlite3.c #define MEM5LINK(idx) ((Mem5Link *)(&mem5.zPool[(idx)*mem5.szAtom])) mem5 18676 ext/sqlite3/libsqlite/sqlite3.c assert( i>=0 && i<mem5.nBlock ); mem5 18678 ext/sqlite3/libsqlite/sqlite3.c assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize ); mem5 18683 ext/sqlite3/libsqlite/sqlite3.c mem5.aiFreelist[iLogsize] = next; mem5 18698 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem5.mutex) ); mem5 18699 ext/sqlite3/libsqlite/sqlite3.c assert( i>=0 && i<mem5.nBlock ); mem5 18701 ext/sqlite3/libsqlite/sqlite3.c assert( (mem5.aCtrl[i] & CTRL_LOGSIZE)==iLogsize ); mem5 18703 ext/sqlite3/libsqlite/sqlite3.c x = MEM5LINK(i)->next = mem5.aiFreelist[iLogsize]; mem5 18706 ext/sqlite3/libsqlite/sqlite3.c assert( x<mem5.nBlock ); mem5 18709 ext/sqlite3/libsqlite/sqlite3.c mem5.aiFreelist[iLogsize] = i; mem5 18718 ext/sqlite3/libsqlite/sqlite3.c sqlite3_mutex_enter(mem5.mutex); mem5 18721 ext/sqlite3/libsqlite/sqlite3.c sqlite3_mutex_leave(mem5.mutex); mem5 18732 ext/sqlite3/libsqlite/sqlite3.c int i = (int)(((u8 *)p-mem5.zPool)/mem5.szAtom); mem5 18733 ext/sqlite3/libsqlite/sqlite3.c assert( i>=0 && i<mem5.nBlock ); mem5 18734 ext/sqlite3/libsqlite/sqlite3.c iSize = mem5.szAtom * (1 << (mem5.aCtrl[i]&CTRL_LOGSIZE)); mem5 18760 ext/sqlite3/libsqlite/sqlite3.c if( (u32)nByte>mem5.maxRequest ){ mem5 18761 ext/sqlite3/libsqlite/sqlite3.c mem5.maxRequest = nByte; mem5 18772 ext/sqlite3/libsqlite/sqlite3.c for(iFullSz=mem5.szAtom, iLogsize=0; iFullSz<nByte; iFullSz *= 2, iLogsize++){} mem5 18778 ext/sqlite3/libsqlite/sqlite3.c for(iBin=iLogsize; iBin<=LOGMAX && mem5.aiFreelist[iBin]<0; iBin++){} mem5 18784 ext/sqlite3/libsqlite/sqlite3.c i = mem5.aiFreelist[iBin]; mem5 18791 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[i+newSize] = CTRL_FREE | iBin; mem5 18794 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[i] = iLogsize; mem5 18797 ext/sqlite3/libsqlite/sqlite3.c mem5.nAlloc++; mem5 18798 ext/sqlite3/libsqlite/sqlite3.c mem5.totalAlloc += iFullSz; mem5 18799 ext/sqlite3/libsqlite/sqlite3.c mem5.totalExcess += iFullSz - nByte; mem5 18800 ext/sqlite3/libsqlite/sqlite3.c mem5.currentCount++; mem5 18801 ext/sqlite3/libsqlite/sqlite3.c mem5.currentOut += iFullSz; mem5 18802 ext/sqlite3/libsqlite/sqlite3.c if( mem5.maxCount<mem5.currentCount ) mem5.maxCount = mem5.currentCount; mem5 18803 ext/sqlite3/libsqlite/sqlite3.c if( mem5.maxOut<mem5.currentOut ) mem5.maxOut = mem5.currentOut; mem5 18808 ext/sqlite3/libsqlite/sqlite3.c memset(&mem5.zPool[i*mem5.szAtom], 0xAA, iFullSz); mem5 18812 ext/sqlite3/libsqlite/sqlite3.c return (void*)&mem5.zPool[i*mem5.szAtom]; mem5 18825 ext/sqlite3/libsqlite/sqlite3.c iBlock = (int)(((u8 *)pOld-mem5.zPool)/mem5.szAtom); mem5 18828 ext/sqlite3/libsqlite/sqlite3.c assert( iBlock>=0 && iBlock<mem5.nBlock ); mem5 18829 ext/sqlite3/libsqlite/sqlite3.c assert( ((u8 *)pOld-mem5.zPool)%mem5.szAtom==0 ); mem5 18830 ext/sqlite3/libsqlite/sqlite3.c assert( (mem5.aCtrl[iBlock] & CTRL_FREE)==0 ); mem5 18832 ext/sqlite3/libsqlite/sqlite3.c iLogsize = mem5.aCtrl[iBlock] & CTRL_LOGSIZE; mem5 18834 ext/sqlite3/libsqlite/sqlite3.c assert( iBlock+size-1<(u32)mem5.nBlock ); mem5 18836 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock] |= CTRL_FREE; mem5 18837 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock+size-1] |= CTRL_FREE; mem5 18838 ext/sqlite3/libsqlite/sqlite3.c assert( mem5.currentCount>0 ); mem5 18839 ext/sqlite3/libsqlite/sqlite3.c assert( mem5.currentOut>=(size*mem5.szAtom) ); mem5 18840 ext/sqlite3/libsqlite/sqlite3.c mem5.currentCount--; mem5 18841 ext/sqlite3/libsqlite/sqlite3.c mem5.currentOut -= size*mem5.szAtom; mem5 18842 ext/sqlite3/libsqlite/sqlite3.c assert( mem5.currentOut>0 || mem5.currentCount==0 ); mem5 18843 ext/sqlite3/libsqlite/sqlite3.c assert( mem5.currentCount>0 || mem5.currentOut==0 ); mem5 18845 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize; mem5 18854 ext/sqlite3/libsqlite/sqlite3.c if( (iBuddy+(1<<iLogsize))>mem5.nBlock ) break; mem5 18855 ext/sqlite3/libsqlite/sqlite3.c if( mem5.aCtrl[iBuddy]!=(CTRL_FREE | iLogsize) ) break; mem5 18859 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBuddy] = CTRL_FREE | iLogsize; mem5 18860 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock] = 0; mem5 18863 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBlock] = CTRL_FREE | iLogsize; mem5 18864 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iBuddy] = 0; mem5 18872 ext/sqlite3/libsqlite/sqlite3.c memset(&mem5.zPool[iBlock*mem5.szAtom], 0x55, size); mem5 18951 ext/sqlite3/libsqlite/sqlite3.c for(iFullSz=mem5.szAtom; iFullSz<n; iFullSz *= 2); mem5 18987 ext/sqlite3/libsqlite/sqlite3.c mem5.mutex = 0; mem5 19000 ext/sqlite3/libsqlite/sqlite3.c mem5.szAtom = (1<<nMinLog); mem5 19001 ext/sqlite3/libsqlite/sqlite3.c while( (int)sizeof(Mem5Link)>mem5.szAtom ){ mem5 19002 ext/sqlite3/libsqlite/sqlite3.c mem5.szAtom = mem5.szAtom << 1; mem5 19005 ext/sqlite3/libsqlite/sqlite3.c mem5.nBlock = (nByte / (mem5.szAtom+sizeof(u8))); mem5 19006 ext/sqlite3/libsqlite/sqlite3.c mem5.zPool = zByte; mem5 19007 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl = (u8 *)&mem5.zPool[mem5.nBlock*mem5.szAtom]; mem5 19010 ext/sqlite3/libsqlite/sqlite3.c mem5.aiFreelist[ii] = -1; mem5 19016 ext/sqlite3/libsqlite/sqlite3.c if( (iOffset+nAlloc)<=mem5.nBlock ){ mem5 19017 ext/sqlite3/libsqlite/sqlite3.c mem5.aCtrl[iOffset] = ii | CTRL_FREE; mem5 19021 ext/sqlite3/libsqlite/sqlite3.c assert((iOffset+nAlloc)>mem5.nBlock); mem5 19026 ext/sqlite3/libsqlite/sqlite3.c mem5.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); mem5 19037 ext/sqlite3/libsqlite/sqlite3.c mem5.mutex = 0; mem5 19062 ext/sqlite3/libsqlite/sqlite3.c nMinLog = memsys5Log(mem5.szAtom); mem5 19064 ext/sqlite3/libsqlite/sqlite3.c for(n=0, j=mem5.aiFreelist[i]; j>=0; j = MEM5LINK(j)->next, n++){} mem5 19065 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "freelist items of size %d: %d\n", mem5.szAtom << i, n); mem5 19067 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.nAlloc = %llu\n", mem5.nAlloc); mem5 19068 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.totalAlloc = %llu\n", mem5.totalAlloc); mem5 19069 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.totalExcess = %llu\n", mem5.totalExcess); mem5 19070 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.currentOut = %u\n", mem5.currentOut); mem5 19071 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.currentCount = %u\n", mem5.currentCount); mem5 19072 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.maxOut = %u\n", mem5.maxOut); mem5 19073 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.maxCount = %u\n", mem5.maxCount); mem5 19074 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mem5.maxRequest = %u\n", mem5.maxRequest);