Example #1
0
File: mem3.c Project: soubok/libset
/*
** Link the chunk at index i into either the appropriate
** small chunk list, or into the large chunk hash table.
*/
static void memsys3Link(int i){
  int size, hash;
  assert( sqlite3_mutex_held(mem.mutex) );
  size = mem.aPool[i-1].u.hdr.size;
  assert( size==mem.aPool[i+size-1].u.hdr.prevSize );
  assert( size>=2 );
  if( size <= MX_SMALL ){
    memsys3LinkIntoList(i, &mem.aiSmall[size-2]);
  }else{
    hash = size % N_HASH;
    memsys3LinkIntoList(i, &mem.aiHash[hash]);
  }
}
/*
** Link the chunk at index i into either the appropriate
** small chunk list, or into the large chunk hash table.
*/
static void memsys3Link(u32 i){
  u32 size, hash;
  assert( sqlite4_mutex_held(mem3.mutex) );
  assert( i>=1 );
  assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );
  size = mem3.aPool[i-1].u.hdr.size4x/4;
  assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );
  assert( size>=2 );
  if( size <= MX_SMALL ){
    memsys3LinkIntoList(i, &mem3.aiSmall[size-2]);
  }else{
    hash = size % N_HASH;
    memsys3LinkIntoList(i, &mem3.aiHash[hash]);
  }
}
Example #3
0
//将第i项插入链表中。
static void memsys3Link(u32 i) {
    u32 size, hash;
    assert( sqlite3_mutex_held(mem3.mutex) );
    assert( i>=1 );
    assert( (mem3.aPool[i-1].u.hdr.size4x & 1)==0 );
    size = mem3.aPool[i-1].u.hdr.size4x/4;  //用来判断是block还是chunk
    assert( size==mem3.aPool[i+size-1].u.hdr.prevSize );
    assert( size>=2 );               //若只是一个block,则终止程序
    if( size <= MX_SMALL ) {
        memsys3LinkIntoList(i, &mem3.aiSmall[size-2]);  //如果size小于10,将i块加入小chunk
    } else {
        hash = size % N_HASH;
        memsys3LinkIntoList(i, &mem3.aiHash[hash]);  //将i块加入大chunk
    }
}