• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/Heimdal-398.1.2/lib/sqlite/

Lines Matching defs:mem3

15500 /************** Begin file mem3.c ********************************************/
15564 ** We often identify a chunk by its index in mem3.aPool[]. When
15572 ** Pointers to the head of the list are stored in mem3.aiSmall[]
15573 ** for smaller chunks and mem3.aiHash[] for larger chunks.
15587 u32 next; /* Index in mem3.aPool[] of next free chunk */
15588 u32 prev; /* Index in mem3.aPool[] of previous free chunk */
15595 ** into a single structure named "mem3". This is to keep the
15638 } mem3 = { 97535575 };
15640 #define mem3 GLOBAL(struct Mem3Global, mem3)
15643 ** Unlink the chunk at mem3.aPool[i] from list it is currently
15647 u32 next = mem3.aPool[i].u.list.next;
15648 u32 prev = mem3.aPool[i].u.list.prev;
15649 assert( sqlite3_mutex_held(mem3.mutex) );
15653 mem3.aPool[prev].u.list.next = next;
15656 mem3.aPool[next].u.list.prev = prev;
15658 mem3.aPool[i].u.list.next = 0;
15659 mem3.aPool[i].u.list.prev = 0;
15668 assert( sqlite3_mutex_held(mem3.mutex) );
15669 assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );
15671 size = mem3.aPool[i-1].u.hdr.size4x/4;
15672 assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );
15675 memsys3UnlinkFromList(i, &mem3.aiSmall[size-2]);
15678 memsys3UnlinkFromList(i, &mem3.aiHash[hash]);
15683 ** Link the chunk at mem3.aPool[i] so that is on the list rooted
15687 assert( sqlite3_mutex_held(mem3.mutex) );
15688 mem3.aPool[i].u.list.next = *pRoot;
15689 mem3.aPool[i].u.list.prev = 0;
15691 mem3.aPool[*pRoot].u.list.prev = i;
15702 assert( sqlite3_mutex_held(mem3.mutex) );
15704 assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );
15705 size = mem3.aPool[i-1].u.hdr.size4x/4;
15706 assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );
15709 memsys3LinkIntoList(i, &mem3.aiSmall[size-2]);
15712 memsys3LinkIntoList(i, &mem3.aiHash[hash]);
15722 if( sqlite3GlobalConfig.bMemstat==0 && mem3.mutex==0 ){
15723 mem3.mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MEM);
15725 sqlite3_mutex_enter(mem3.mutex);
15728 sqlite3_mutex_leave(mem3.mutex);
15735 if( !mem3.alarmBusy ){
15736 mem3.alarmBusy = 1;
15737 assert( sqlite3_mutex_held(mem3.mutex) );
15738 sqlite3_mutex_leave(mem3.mutex);
15740 sqlite3_mutex_enter(mem3.mutex);
15741 mem3.alarmBusy = 0;
15753 assert( sqlite3_mutex_held(mem3.mutex) );
15755 assert( mem3.aPool[i-1].u.hdr.size4x/4==nBlock );
15756 assert( mem3.aPool[i+nBlock-1].u.hdr.prevSize==nBlock );
15757 x = mem3.aPool[i-1].u.hdr.size4x;
15758 mem3.aPool[i-1].u.hdr.size4x = nBlock*4 | 1 | (x&2);
15759 mem3.aPool[i+nBlock-1].u.hdr.prevSize = nBlock;
15760 mem3.aPool[i+nBlock-1].u.hdr.size4x |= 2;
15761 return &mem3.aPool[i];
15765 ** Carve a piece off of the end of the mem3.iMaster free chunk.
15770 assert( sqlite3_mutex_held(mem3.mutex) );
15771 assert( mem3.szMaster>=nBlock );
15772 if( nBlock>=mem3.szMaster-1 ){
15774 void *p = memsys3Checkout(mem3.iMaster, mem3.szMaster);
15775 mem3.iMaster = 0;
15776 mem3.szMaster = 0;
15777 mem3.mnMaster = 0;
15782 newi = mem3.iMaster + mem3.szMaster - nBlock;
15783 assert( newi > mem3.iMaster+1 );
15784 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = nBlock;
15785 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x |= 2;
15786 mem3.aPool[newi-1].u.hdr.size4x = nBlock*4 + 1;
15787 mem3.szMaster -= nBlock;
15788 mem3.aPool[newi-1].u.hdr.prevSize = mem3.szMaster;
15789 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;
15790 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;
15791 if( mem3.szMaster < mem3.mnMaster ){
15792 mem3.mnMaster = mem3.szMaster;
15794 return (void*)&mem3.aPool[newi];
15801 ** mem3.aiSmall[] or mem3.aiHash[].
15806 ** If it sees a chunk that is larger than mem3.iMaster, it replaces
15807 ** the current mem3.iMaster with the new larger chunk. In order for
15808 ** this mem3.iMaster replacement to work, the master chunk must be
15817 assert( sqlite3_mutex_held(mem3.mutex) );
15819 iNext = mem3.aPool[i].u.list.next;
15820 size = mem3.aPool[i-1].u.hdr.size4x;
15824 assert( i > mem3.aPool[i-1].u.hdr.prevSize );
15825 prev = i - mem3.aPool[i-1].u.hdr.prevSize;
15827 iNext = mem3.aPool[prev].u.list.next;
15831 x = mem3.aPool[prev-1].u.hdr.size4x & 2;
15832 mem3.aPool[prev-1].u.hdr.size4x = size*4 | x;
15833 mem3.aPool[prev+size-1].u.hdr.prevSize = size;
15839 if( size>mem3.szMaster ){
15840 mem3.iMaster = i;
15841 mem3.szMaster = size;
15858 assert( sqlite3_mutex_held(mem3.mutex) );
15873 i = mem3.aiSmall[nBlock-2];
15875 memsys3UnlinkFromList(i, &mem3.aiSmall[nBlock-2]);
15880 for(i=mem3.aiHash[hash]; i>0; i=mem3.aPool[i].u.list.next){
15881 if( mem3.aPool[i-1].u.hdr.size4x/4==nBlock ){
15882 memsys3UnlinkFromList(i, &mem3.aiHash[hash]);
15892 if( mem3.szMaster>=nBlock ){
15904 for(toFree=nBlock*16; toFree<(mem3.nPool*16); toFree *= 2){
15906 if( mem3.iMaster ){
15907 memsys3Link(mem3.iMaster);
15908 mem3.iMaster = 0;
15909 mem3.szMaster = 0;
15912 memsys3Merge(&mem3.aiHash[i]);
15915 memsys3Merge(&mem3.aiSmall[i]);
15917 if( mem3.szMaster ){
15918 memsys3Unlink(mem3.iMaster);
15919 if( mem3.szMaster>=nBlock ){
15939 assert( sqlite3_mutex_held(mem3.mutex) );
15940 assert( p>mem3.aPool && p<&mem3.aPool[mem3.nPool] );
15941 i = p - mem3.aPool;
15942 assert( (mem3.aPool[i-1].u.hdr.size4x&1)==1 );
15943 size = mem3.aPool[i-1].u.hdr.size4x/4;
15944 assert( i+size<=mem3.nPool+1 );
15945 mem3.aPool[i-1].u.hdr.size4x &= ~1;
15946 mem3.aPool[i+size-1].u.hdr.prevSize = size;
15947 mem3.aPool[i+size-1].u.hdr.size4x &= ~2;
15951 if( mem3.iMaster ){
15952 while( (mem3.aPool[mem3.iMaster-1].u.hdr.size4x&2)==0 ){
15953 size = mem3.aPool[mem3.iMaster-1].u.hdr.prevSize;
15954 mem3.iMaster -= size;
15955 mem3.szMaster += size;
15956 memsys3Unlink(mem3.iMaster);
15957 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;
15958 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;
15959 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;
15961 x = mem3.aPool[mem3.iMaster-1].u.hdr.size4x & 2;
15962 while( (mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x&1)==0 ){
15963 memsys3Unlink(mem3.iMaster+mem3.szMaster);
15964 mem3.szMaster += mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.size4x/4;
15965 mem3.aPool[mem3.iMaster-1].u.hdr.size4x = mem3.szMaster*4 | x;
15966 mem3.aPool[mem3.iMaster+mem3.szMaster-1].u.hdr.prevSize = mem3.szMaster;
16057 /* Store a pointer to the memory block in global structure mem3. */
16059 mem3.aPool = (Mem3Block *)sqlite3GlobalConfig.pHeap;
16060 mem3.nPool = (sqlite3GlobalConfig.nHeap / sizeof(Mem3Block)) - 2;
16063 mem3.szMaster = mem3.nPool;
16064 mem3.mnMaster = mem3.szMaster;
16065 mem3.iMaster = 1;
16066 mem3.aPool[0].u.hdr.size4x = (mem3.szMaster<<2) + 2;
16067 mem3.aPool[mem3.nPool].u.hdr.prevSize = mem3.nPool;
16068 mem3.aPool[mem3.nPool].u.hdr.size4x = 1;
16078 mem3.mutex = 0;
16105 for(i=1; i<=mem3.nPool; i+=size/4){
16106 size = mem3.aPool[i-1].u.hdr.size4x;
16108 fprintf(out, "%p size error\n", &mem3.aPool[i]);
16112 if( (size&1)==0 && mem3.aPool[i+size/4-1].u.hdr.prevSize!=size/4 ){
16113 fprintf(out, "%p tail size does not match\n", &mem3.aPool[i]);
16117 if( ((mem3.aPool[i+size/4-1].u.hdr.size4x&2)>>1)!=(size&1) ){
16118 fprintf(out, "%p tail checkout bit is incorrect\n", &mem3.aPool[i]);
16123 fprintf(out, "%p %6d bytes checked out\n", &mem3.aPool[i], (size/4)*8-8);
16125 fprintf(out, "%p %6d bytes free%s\n", &mem3.aPool[i], (size/4)*8-8,
16126 i==mem3.iMaster ? " **master**" : "");
16130 if( mem3.aiSmall[i]==0 ) continue;
16132 for(j = mem3.aiSmall[i]; j>0; j=mem3.aPool[j].u.list.next){
16133 fprintf(out, " %p(%d)", &mem3.aPool[j],
16134 (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);
16139 if( mem3.aiHash[i]==0 ) continue;
16141 for(j = mem3.aiHash[i]; j>0; j=mem3.aPool[j].u.list.next){
16142 fprintf(out, " %p(%d)", &mem3.aPool[j],
16143 (mem3.aPool[j-1].u.hdr.size4x/4)*8-8);
16147 fprintf(out, "master=%d\n", mem3.iMaster);
16148 fprintf(out, "nowUsed=%d\n", mem3.nPool*8 - mem3.szMaster*8);
16149 fprintf(out, "mxUsed=%d\n", mem3.nPool*8 - mem3.mnMaster*8);
16150 sqlite3_mutex_leave(mem3.mutex);
16188 /************** End of mem3.c ************************************************/
110548 ** mem5.c/mem3.c methods. If neither ENABLE_MEMSYS3 nor