mem3 15551 ext/sqlite3/libsqlite/sqlite3.c } mem3 = { 97535575 }; mem3 15553 ext/sqlite3/libsqlite/sqlite3.c #define mem3 GLOBAL(struct Mem3Global, mem3) mem3 15560 ext/sqlite3/libsqlite/sqlite3.c u32 next = mem3.aPool[i].u.list.next; mem3 15561 ext/sqlite3/libsqlite/sqlite3.c u32 prev = mem3.aPool[i].u.list.prev; mem3 15562 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15566 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[prev].u.list.next = next; mem3 15569 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[next].u.list.prev = prev; mem3 15571 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i].u.list.next = 0; mem3 15572 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i].u.list.prev = 0; mem3 15581 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15582 ext/sqlite3/libsqlite/sqlite3.c assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 ); mem3 15584 ext/sqlite3/libsqlite/sqlite3.c size = mem3.aPool[i-1].u.hdr.size4x/4; mem3 15585 ext/sqlite3/libsqlite/sqlite3.c assert( size==mem3.aPool[i+size-1].u.hdr.prevSize ); mem3 15588 ext/sqlite3/libsqlite/sqlite3.c memsys3UnlinkFromList(i, &mem3.aiSmall[size-2]); mem3 15591 ext/sqlite3/libsqlite/sqlite3.c memsys3UnlinkFromList(i, &mem3.aiHash[hash]); mem3 15600 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15601 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i].u.list.next = *pRoot; mem3 15602 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i].u.list.prev = 0; mem3 15604 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[*pRoot].u.list.prev = i; mem3 15615 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15617 ext/sqlite3/libsqlite/sqlite3.c assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 ); mem3 15618 ext/sqlite3/libsqlite/sqlite3.c size = mem3.aPool[i-1].u.hdr.size4x/4; mem3 15619 ext/sqlite3/libsqlite/sqlite3.c assert( size==mem3.aPool[i+size-1].u.hdr.prevSize ); mem3 15622 ext/sqlite3/libsqlite/sqlite3.c memsys3LinkIntoList(i, &mem3.aiSmall[size-2]); mem3 15625 ext/sqlite3/libsqlite/sqlite3.c memsys3LinkIntoList(i, &mem3.aiHash[hash]); mem3 15635 ext/sqlite3/libsqlite/sqlite3.c if( sqlite3GlobalConfig.bMemstat==0 && mem3.mutex==0 ){ mem3 15636 ext/sqlite3/libsqlite/sqlite3.c mem3.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM); mem3 15638 ext/sqlite3/libsqlite/sqlite3.c sqlite3_mutex_enter(mem3.mutex); mem3 15641 ext/sqlite3/libsqlite/sqlite3.c sqlite3_mutex_leave(mem3.mutex); mem3 15648 ext/sqlite3/libsqlite/sqlite3.c if( !mem3.alarmBusy ){ mem3 15649 ext/sqlite3/libsqlite/sqlite3.c mem3.alarmBusy = 1; mem3 15650 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15651 ext/sqlite3/libsqlite/sqlite3.c sqlite3_mutex_leave(mem3.mutex); mem3 15653 ext/sqlite3/libsqlite/sqlite3.c sqlite3_mutex_enter(mem3.mutex); mem3 15654 ext/sqlite3/libsqlite/sqlite3.c mem3.alarmBusy = 0; mem3 15666 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15668 ext/sqlite3/libsqlite/sqlite3.c assert( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ); mem3 15669 ext/sqlite3/libsqlite/sqlite3.c assert( mem3.aPool[i+nBlock-1].u.hdr.prevSize==nBlock ); mem3 15670 ext/sqlite3/libsqlite/sqlite3.c x = mem3.aPool[i-1].u.hdr.size4x; mem3 15671 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i-1].u.hdr.size4x = nBlock*4 | 1 | (x&2); mem3 15672 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i+nBlock-1].u.hdr.prevSize = nBlock; mem3 15673 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i+nBlock-1].u.hdr.size4x |= 2; mem3 15674 ext/sqlite3/libsqlite/sqlite3.c return &mem3.aPool[i]; mem3 15683 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15684 ext/sqlite3/libsqlite/sqlite3.c assert( mem3.szMaster>=nBlock ); mem3 15685 ext/sqlite3/libsqlite/sqlite3.c if( nBlock>=mem3.szMaster-1 ){ mem3 15687 ext/sqlite3/libsqlite/sqlite3.c void *p = memsys3Checkout(mem3.iMaster, mem3.szMaster); mem3 15688 ext/sqlite3/libsqlite/sqlite3.c mem3.iMaster = 0; mem3 15689 ext/sqlite3/libsqlite/sqlite3.c mem3.szMaster = 0; mem3 15690 ext/sqlite3/libsqlite/sqlite3.c mem3.mnMaster = 0; mem3 15695 ext/sqlite3/libsqlite/sqlite3.c newi = mem3.iMaster + mem3.szMaster - nBlock; mem3 15696 ext/sqlite3/libsqlite/sqlite3.c assert( newi > mem3.iMaster+1 ); mem3 15697 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = nBlock; mem3 15698 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x |= 2; mem3 15699 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[newi-1].u.hdr.size4x = nBlock*4 + 1; mem3 15700 ext/sqlite3/libsqlite/sqlite3.c mem3.szMaster -= nBlock; mem3 15701 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[newi-1].u.hdr.prevSize = mem3.szMaster; mem3 15702 ext/sqlite3/libsqlite/sqlite3.c x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; mem3 15703 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; mem3 15704 ext/sqlite3/libsqlite/sqlite3.c if( mem3.szMaster < mem3.mnMaster ){ mem3 15705 ext/sqlite3/libsqlite/sqlite3.c mem3.mnMaster = mem3.szMaster; mem3 15707 ext/sqlite3/libsqlite/sqlite3.c return (void*)&mem3.aPool[newi]; mem3 15730 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15732 ext/sqlite3/libsqlite/sqlite3.c iNext = mem3.aPool[i].u.list.next; mem3 15733 ext/sqlite3/libsqlite/sqlite3.c size = mem3.aPool[i-1].u.hdr.size4x; mem3 15737 ext/sqlite3/libsqlite/sqlite3.c assert( i > mem3.aPool[i-1].u.hdr.prevSize ); mem3 15738 ext/sqlite3/libsqlite/sqlite3.c prev = i - mem3.aPool[i-1].u.hdr.prevSize; mem3 15740 ext/sqlite3/libsqlite/sqlite3.c iNext = mem3.aPool[prev].u.list.next; mem3 15744 ext/sqlite3/libsqlite/sqlite3.c x = mem3.aPool[prev-1].u.hdr.size4x & 2; mem3 15745 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[prev-1].u.hdr.size4x = size*4 | x; mem3 15746 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[prev+size-1].u.hdr.prevSize = size; mem3 15752 ext/sqlite3/libsqlite/sqlite3.c if( size>mem3.szMaster ){ mem3 15753 ext/sqlite3/libsqlite/sqlite3.c mem3.iMaster = i; mem3 15754 ext/sqlite3/libsqlite/sqlite3.c mem3.szMaster = size; mem3 15771 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15786 ext/sqlite3/libsqlite/sqlite3.c i = mem3.aiSmall[nBlock-2]; mem3 15788 ext/sqlite3/libsqlite/sqlite3.c memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]); mem3 15793 ext/sqlite3/libsqlite/sqlite3.c for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){ mem3 15794 ext/sqlite3/libsqlite/sqlite3.c if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){ mem3 15795 ext/sqlite3/libsqlite/sqlite3.c memsys3UnlinkFromList(i, &mem3.aiHash[hash]); mem3 15805 ext/sqlite3/libsqlite/sqlite3.c if( mem3.szMaster>=nBlock ){ mem3 15817 ext/sqlite3/libsqlite/sqlite3.c for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){ mem3 15819 ext/sqlite3/libsqlite/sqlite3.c if( mem3.iMaster ){ mem3 15820 ext/sqlite3/libsqlite/sqlite3.c memsys3Link(mem3.iMaster); mem3 15821 ext/sqlite3/libsqlite/sqlite3.c mem3.iMaster = 0; mem3 15822 ext/sqlite3/libsqlite/sqlite3.c mem3.szMaster = 0; mem3 15825 ext/sqlite3/libsqlite/sqlite3.c memsys3Merge(&mem3.aiHash[i]); mem3 15828 ext/sqlite3/libsqlite/sqlite3.c memsys3Merge(&mem3.aiSmall[i]); mem3 15830 ext/sqlite3/libsqlite/sqlite3.c if( mem3.szMaster ){ mem3 15831 ext/sqlite3/libsqlite/sqlite3.c memsys3Unlink(mem3.iMaster); mem3 15832 ext/sqlite3/libsqlite/sqlite3.c if( mem3.szMaster>=nBlock ){ mem3 15852 ext/sqlite3/libsqlite/sqlite3.c assert( sqlite3_mutex_held(mem3.mutex) ); mem3 15853 ext/sqlite3/libsqlite/sqlite3.c assert( p>mem3.aPool && p<&mem3.aPool[mem3.nPool] ); mem3 15854 ext/sqlite3/libsqlite/sqlite3.c i = p - mem3.aPool; mem3 15855 ext/sqlite3/libsqlite/sqlite3.c assert( (mem3.aPool[i-1].u.hdr.size4x&1)==1 ); mem3 15856 ext/sqlite3/libsqlite/sqlite3.c size = mem3.aPool[i-1].u.hdr.size4x/4; mem3 15857 ext/sqlite3/libsqlite/sqlite3.c assert( i+size<=mem3.nPool+1 ); mem3 15858 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i-1].u.hdr.size4x &= ~1; mem3 15859 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i+size-1].u.hdr.prevSize = size; mem3 15860 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[i+size-1].u.hdr.size4x &= ~2; mem3 15864 ext/sqlite3/libsqlite/sqlite3.c if( mem3.iMaster ){ mem3 15865 ext/sqlite3/libsqlite/sqlite3.c while( (mem3.aPool[mem3.iMaster-1].u.hdr.size4x&2)==0 ){ mem3 15866 ext/sqlite3/libsqlite/sqlite3.c size = mem3.aPool[mem3.iMaster-1].u.hdr.prevSize; mem3 15867 ext/sqlite3/libsqlite/sqlite3.c mem3.iMaster -= size; mem3 15868 ext/sqlite3/libsqlite/sqlite3.c mem3.szMaster += size; mem3 15869 ext/sqlite3/libsqlite/sqlite3.c memsys3Unlink(mem3.iMaster); mem3 15870 ext/sqlite3/libsqlite/sqlite3.c x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; mem3 15871 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; mem3 15872 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster; mem3 15874 ext/sqlite3/libsqlite/sqlite3.c x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2; mem3 15875 ext/sqlite3/libsqlite/sqlite3.c while( (mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x&1)==0 ){ mem3 15876 ext/sqlite3/libsqlite/sqlite3.c memsys3Unlink(mem3.iMaster+mem3.szMaster); mem3 15877 ext/sqlite3/libsqlite/sqlite3.c mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4; mem3 15878 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x; mem3 15879 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster; mem3 15972 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool = (Mem3Block *)sqlite3GlobalConfig.pHeap; mem3 15973 ext/sqlite3/libsqlite/sqlite3.c mem3.nPool = (sqlite3GlobalConfig.nHeap / sizeof(Mem3Block)) - 2; mem3 15976 ext/sqlite3/libsqlite/sqlite3.c mem3.szMaster = mem3.nPool; mem3 15977 ext/sqlite3/libsqlite/sqlite3.c mem3.mnMaster = mem3.szMaster; mem3 15978 ext/sqlite3/libsqlite/sqlite3.c mem3.iMaster = 1; mem3 15979 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[0].u.hdr.size4x = (mem3.szMaster<<2) + 2; mem3 15980 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.nPool].u.hdr.prevSize = mem3.nPool; mem3 15981 ext/sqlite3/libsqlite/sqlite3.c mem3.aPool[mem3.nPool].u.hdr.size4x = 1; mem3 15991 ext/sqlite3/libsqlite/sqlite3.c mem3.mutex = 0; mem3 16018 ext/sqlite3/libsqlite/sqlite3.c for(i=1; i<=mem3.nPool; i+=size/4){ mem3 16019 ext/sqlite3/libsqlite/sqlite3.c size = mem3.aPool[i-1].u.hdr.size4x; mem3 16021 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "%p size error\n", &mem3.aPool[i]); mem3 16025 ext/sqlite3/libsqlite/sqlite3.c if( (size&1)==0 && mem3.aPool[i+size/4-1].u.hdr.prevSize!=size/4 ){ mem3 16026 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "%p tail size does not match\n", &mem3.aPool[i]); mem3 16030 ext/sqlite3/libsqlite/sqlite3.c if( ((mem3.aPool[i+size/4-1].u.hdr.size4x&2)>>1)!=(size&1) ){ mem3 16031 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "%p tail checkout bit is incorrect\n", &mem3.aPool[i]); mem3 16036 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "%p %6d bytes checked out\n", &mem3.aPool[i], (size/4)*8-8); mem3 16038 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "%p %6d bytes free%s\n", &mem3.aPool[i], (size/4)*8-8, mem3 16039 ext/sqlite3/libsqlite/sqlite3.c i==mem3.iMaster ? " **master**" : ""); mem3 16043 ext/sqlite3/libsqlite/sqlite3.c if( mem3.aiSmall[i]==0 ) continue; mem3 16045 ext/sqlite3/libsqlite/sqlite3.c for(j = mem3.aiSmall[i]; j>0; j=mem3.aPool[j].u.list.next){ mem3 16046 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, " %p(%d)", &mem3.aPool[j], mem3 16047 ext/sqlite3/libsqlite/sqlite3.c (mem3.aPool[j-1].u.hdr.size4x/4)*8-8); mem3 16052 ext/sqlite3/libsqlite/sqlite3.c if( mem3.aiHash[i]==0 ) continue; mem3 16054 ext/sqlite3/libsqlite/sqlite3.c for(j = mem3.aiHash[i]; j>0; j=mem3.aPool[j].u.list.next){ mem3 16055 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, " %p(%d)", &mem3.aPool[j], mem3 16056 ext/sqlite3/libsqlite/sqlite3.c (mem3.aPool[j-1].u.hdr.size4x/4)*8-8); mem3 16060 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "master=%d\n", mem3.iMaster); mem3 16061 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "nowUsed=%d\n", mem3.nPool*8 - mem3.szMaster*8); mem3 16062 ext/sqlite3/libsqlite/sqlite3.c fprintf(out, "mxUsed=%d\n", mem3.nPool*8 - mem3.mnMaster*8); mem3 16063 ext/sqlite3/libsqlite/sqlite3.c sqlite3_mutex_leave(mem3.mutex);