亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? hash.c

?? sqlite 3.3.8 支持加密的版本
?? C
字號:
/*
** 2001 September 22
**
** The author disclaims copyright to this source code.  In place of
** a legal notice, here is a blessing:
**
**    May you do good and not evil.
**    May you find forgiveness for yourself and forgive others.
**    May you share freely, never taking more than you give.
**
*************************************************************************
** This is the implementation of generic hash-tables
** used in SQLite.
**
** $Id: hash.c,v 1.23 2006/10/12 21:34:21 rmsimpson Exp $
*/
#include "sqliteInt.h"
#include <assert.h>

/* Turn bulk memory into a hash table object by initializing the
** fields of the Hash structure.
**
** "pNew" is a pointer to the hash table that is to be initialized.
** keyClass is one of the constants SQLITE_HASH_INT, SQLITE_HASH_POINTER,
** SQLITE_HASH_BINARY, or SQLITE_HASH_STRING.  The value of keyClass 
** determines what kind of key the hash table will use.  "copyKey" is
** true if the hash table should make its own private copy of keys and
** false if it should just use the supplied pointer.  CopyKey only makes
** sense for SQLITE_HASH_STRING and SQLITE_HASH_BINARY and is ignored
** for other key classes.
*/
void sqlite3HashInit(Hash *pNew, int keyClass, int copyKey){
  assert( pNew!=0 );
  assert( keyClass>=SQLITE_HASH_STRING && keyClass<=SQLITE_HASH_BINARY );
  pNew->keyClass = keyClass;
#if 0
  if( keyClass==SQLITE_HASH_POINTER || keyClass==SQLITE_HASH_INT ) copyKey = 0;
#endif
  pNew->copyKey = copyKey;
  pNew->first = 0;
  pNew->count = 0;
  pNew->htsize = 0;
  pNew->ht = 0;
  pNew->xMalloc = sqlite3MallocX;
  pNew->xFree = sqlite3FreeX;
}

/* Remove all entries from a hash table.  Reclaim all memory.
** Call this routine to delete a hash table or to reset a hash table
** to the empty state.
*/
void sqlite3HashClear(Hash *pH){
  HashElem *elem;         /* For looping over all elements of the table */

  assert( pH!=0 );
  elem = pH->first;
  pH->first = 0;
  if( pH->ht ) pH->xFree(pH->ht);
  pH->ht = 0;
  pH->htsize = 0;
  while( elem ){
    HashElem *next_elem = elem->next;
    if( pH->copyKey && elem->pKey ){
      pH->xFree(elem->pKey);
    }
    pH->xFree(elem);
    elem = next_elem;
  }
  pH->count = 0;
}

#if 0 /* NOT USED */
/*
** Hash and comparison functions when the mode is SQLITE_HASH_INT
*/
static int intHash(const void *pKey, int nKey){
  return nKey ^ (nKey<<8) ^ (nKey>>8);
}
static int intCompare(const void *pKey1, int n1, const void *pKey2, int n2){
  return n2 - n1;
}
#endif

#if 0 /* NOT USED */
/*
** Hash and comparison functions when the mode is SQLITE_HASH_POINTER
*/
static int ptrHash(const void *pKey, int nKey){
  uptr x = Addr(pKey);
  return x ^ (x<<8) ^ (x>>8);
}
static int ptrCompare(const void *pKey1, int n1, const void *pKey2, int n2){
  if( pKey1==pKey2 ) return 0;
  if( pKey1<pKey2 ) return -1;
  return 1;
}
#endif

/*
** Hash and comparison functions when the mode is SQLITE_HASH_STRING
*/
static int strHash(const void *pKey, int nKey){
  const char *z = (const char *)pKey;
  int h = 0;
  if( nKey<=0 ) nKey = strlen(z);
  while( nKey > 0  ){
    h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++];
    nKey--;
  }
  return h & 0x7fffffff;
}
static int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){
  if( n1!=n2 ) return 1;
  return sqlite3StrNICmp((const char*)pKey1,(const char*)pKey2,n1);
}

/*
** Hash and comparison functions when the mode is SQLITE_HASH_BINARY
*/
static int binHash(const void *pKey, int nKey){
  int h = 0;
  const char *z = (const char *)pKey;
  while( nKey-- > 0 ){
    h = (h<<3) ^ h ^ *(z++);
  }
  return h & 0x7fffffff;
}
static int binCompare(const void *pKey1, int n1, const void *pKey2, int n2){
  if( n1!=n2 ) return 1;
  return memcmp(pKey1,pKey2,n1);
}

/*
** Return a pointer to the appropriate hash function given the key class.
**
** The C syntax in this function definition may be unfamilar to some 
** programmers, so we provide the following additional explanation:
**
** The name of the function is "hashFunction".  The function takes a
** single parameter "keyClass".  The return value of hashFunction()
** is a pointer to another function.  Specifically, the return value
** of hashFunction() is a pointer to a function that takes two parameters
** with types "const void*" and "int" and returns an "int".
*/
static int (*hashFunction(int keyClass))(const void*,int){
#if 0  /* HASH_INT and HASH_POINTER are never used */
  switch( keyClass ){
    case SQLITE_HASH_INT:     return &intHash;
    case SQLITE_HASH_POINTER: return &ptrHash;
    case SQLITE_HASH_STRING:  return &strHash;
    case SQLITE_HASH_BINARY:  return &binHash;;
    default: break;
  }
  return 0;
#else
  if( keyClass==SQLITE_HASH_STRING ){
    return &strHash;
  }else{
    assert( keyClass==SQLITE_HASH_BINARY );
    return &binHash;
  }
#endif
}

/*
** Return a pointer to the appropriate hash function given the key class.
**
** For help in interpreted the obscure C code in the function definition,
** see the header comment on the previous function.
*/
static int (*compareFunction(int keyClass))(const void*,int,const void*,int){
#if 0 /* HASH_INT and HASH_POINTER are never used */
  switch( keyClass ){
    case SQLITE_HASH_INT:     return &intCompare;
    case SQLITE_HASH_POINTER: return &ptrCompare;
    case SQLITE_HASH_STRING:  return &strCompare;
    case SQLITE_HASH_BINARY:  return &binCompare;
    default: break;
  }
  return 0;
#else
  if( keyClass==SQLITE_HASH_STRING ){
    return &strCompare;
  }else{
    assert( keyClass==SQLITE_HASH_BINARY );
    return &binCompare;
  }
#endif
}

/* Link an element into the hash table
*/
static void insertElement(
  Hash *pH,              /* The complete hash table */
  struct _ht *pEntry,    /* The entry into which pNew is inserted */
  HashElem *pNew         /* The element to be inserted */
){
  HashElem *pHead;       /* First element already in pEntry */
  pHead = pEntry->chain;
  if( pHead ){
    pNew->next = pHead;
    pNew->prev = pHead->prev;
    if( pHead->prev ){ pHead->prev->next = pNew; }
    else             { pH->first = pNew; }
    pHead->prev = pNew;
  }else{
    pNew->next = pH->first;
    if( pH->first ){ pH->first->prev = pNew; }
    pNew->prev = 0;
    pH->first = pNew;
  }
  pEntry->count++;
  pEntry->chain = pNew;
}


/* Resize the hash table so that it cantains "new_size" buckets.
** "new_size" must be a power of 2.  The hash table might fail 
** to resize if sqliteMalloc() fails.
*/
static void rehash(Hash *pH, int new_size){
  struct _ht *new_ht;            /* The new hash table */
  HashElem *elem, *next_elem;    /* For looping over existing elements */
  int (*xHash)(const void*,int); /* The hash function */

  assert( (new_size & (new_size-1))==0 );
  new_ht = (struct _ht *)pH->xMalloc( new_size*sizeof(struct _ht) );
  if( new_ht==0 ) return;
  if( pH->ht ) pH->xFree(pH->ht);
  pH->ht = new_ht;
  pH->htsize = new_size;
  xHash = hashFunction(pH->keyClass);
  for(elem=pH->first, pH->first=0; elem; elem = next_elem){
    int h = (*xHash)(elem->pKey, elem->nKey) & (new_size-1);
    next_elem = elem->next;
    insertElement(pH, &new_ht[h], elem);
  }
}

/* This function (for internal use only) locates an element in an
** hash table that matches the given key.  The hash for this key has
** already been computed and is passed as the 4th parameter.
*/
static HashElem *findElementGivenHash(
  const Hash *pH,     /* The pH to be searched */
  const void *pKey,   /* The key we are searching for */
  int nKey,
  int h               /* The hash for this key. */
){
  HashElem *elem;                /* Used to loop thru the element list */
  int count;                     /* Number of elements left to test */
  int (*xCompare)(const void*,int,const void*,int);  /* comparison function */

  if( pH->ht ){
    struct _ht *pEntry = &pH->ht[h];
    elem = pEntry->chain;
    count = pEntry->count;
    xCompare = compareFunction(pH->keyClass);
    while( count-- && elem ){
      if( (*xCompare)(elem->pKey,elem->nKey,pKey,nKey)==0 ){ 
        return elem;
      }
      elem = elem->next;
    }
  }
  return 0;
}

/* Remove a single entry from the hash table given a pointer to that
** element and a hash on the element's key.
*/
static void removeElementGivenHash(
  Hash *pH,         /* The pH containing "elem" */
  HashElem* elem,   /* The element to be removed from the pH */
  int h             /* Hash value for the element */
){
  struct _ht *pEntry;
  if( elem->prev ){
    elem->prev->next = elem->next; 
  }else{
    pH->first = elem->next;
  }
  if( elem->next ){
    elem->next->prev = elem->prev;
  }
  pEntry = &pH->ht[h];
  if( pEntry->chain==elem ){
    pEntry->chain = elem->next;
  }
  pEntry->count--;
  if( pEntry->count<=0 ){
    pEntry->chain = 0;
  }
  if( pH->copyKey && elem->pKey ){
    pH->xFree(elem->pKey);
  }
  pH->xFree( elem );
  pH->count--;
  if( pH->count<=0 ){
    assert( pH->first==0 );
    assert( pH->count==0 );
    sqlite3HashClear(pH);
  }
}

/* Attempt to locate an element of the hash table pH with a key
** that matches pKey,nKey.  Return the data for this element if it is
** found, or NULL if there is no match.
*/
void *sqlite3HashFind(const Hash *pH, const void *pKey, int nKey){
  int h;             /* A hash on key */
  HashElem *elem;    /* The element that matches key */
  int (*xHash)(const void*,int);  /* The hash function */

  if( pH==0 || pH->ht==0 ) return 0;
  xHash = hashFunction(pH->keyClass);
  assert( xHash!=0 );
  h = (*xHash)(pKey,nKey);
  assert( (pH->htsize & (pH->htsize-1))==0 );
  elem = findElementGivenHash(pH,pKey,nKey, h & (pH->htsize-1));
  return elem ? elem->data : 0;
}

/* Insert an element into the hash table pH.  The key is pKey,nKey
** and the data is "data".
**
** If no element exists with a matching key, then a new
** element is created.  A copy of the key is made if the copyKey
** flag is set.  NULL is returned.
**
** If another element already exists with the same key, then the
** new data replaces the old data and the old data is returned.
** The key is not copied in this instance.  If a malloc fails, then
** the new data is returned and the hash table is unchanged.
**
** If the "data" parameter to this function is NULL, then the
** element corresponding to "key" is removed from the hash table.
*/
void *sqlite3HashInsert(Hash *pH, const void *pKey, int nKey, void *data){
  int hraw;             /* Raw hash value of the key */
  int h;                /* the hash of the key modulo hash table size */
  HashElem *elem;       /* Used to loop thru the element list */
  HashElem *new_elem;   /* New element added to the pH */
  int (*xHash)(const void*,int);  /* The hash function */

  assert( pH!=0 );
  xHash = hashFunction(pH->keyClass);
  assert( xHash!=0 );
  hraw = (*xHash)(pKey, nKey);
  assert( (pH->htsize & (pH->htsize-1))==0 );
  h = hraw & (pH->htsize-1);
  elem = findElementGivenHash(pH,pKey,nKey,h);
  if( elem ){
    void *old_data = elem->data;
    if( data==0 ){
      removeElementGivenHash(pH,elem,h);
    }else{
      elem->data = data;
    }
    return old_data;
  }
  if( data==0 ) return 0;
  new_elem = (HashElem*)pH->xMalloc( sizeof(HashElem) );
  if( new_elem==0 ) return data;
  if( pH->copyKey && pKey!=0 ){
    new_elem->pKey = pH->xMalloc( nKey );
    if( new_elem->pKey==0 ){
      pH->xFree(new_elem);
      return data;
    }
    memcpy((void*)new_elem->pKey, pKey, nKey);
  }else{
    new_elem->pKey = (void*)pKey;
  }
  new_elem->nKey = nKey;
  pH->count++;
  if( pH->htsize==0 ){
    rehash(pH,8);
    if( pH->htsize==0 ){
      pH->count = 0;
      pH->xFree(new_elem);
      return data;
    }
  }
  if( pH->count > pH->htsize ){
    rehash(pH,pH->htsize*2);
  }
  assert( pH->htsize>0 );
  assert( (pH->htsize & (pH->htsize-1))==0 );
  h = hraw & (pH->htsize-1);
  insertElement(pH, &pH->ht[h], new_elem);
  new_elem->data = data;
  return 0;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品国产一区二区三区四区四 | 午夜电影网一区| 91亚洲精华国产精华精华液| 国产精品网站在线观看| 国产乱理伦片在线观看夜一区| 欧美一区二区视频免费观看| 午夜欧美大尺度福利影院在线看| 在线欧美日韩国产| 丝袜美腿亚洲一区| 欧美一区国产二区| 国模套图日韩精品一区二区 | 亚洲天堂成人网| 色诱视频网站一区| 日韩不卡一区二区三区| 日韩欧美国产综合| 日本韩国欧美一区| 亚洲精品视频在线| 欧美日韩一区久久| 久久99精品一区二区三区三区| 久久久精品天堂| 91成人网在线| 国产剧情av麻豆香蕉精品| 亚洲婷婷综合久久一本伊一区| 欧美美女黄视频| 99国产精品国产精品久久| 水蜜桃久久夜色精品一区的特点 | 国产欧美一区二区精品性| 91福利社在线观看| 处破女av一区二区| 日韩电影在线一区二区三区| 国产精品萝li| 亚洲精品一区二区三区香蕉| av成人免费在线| 成人精品视频网站| 国产精品1区2区3区在线观看| 亚洲一二三级电影| 一区在线播放视频| 国产女同性恋一区二区| 3751色影院一区二区三区| 色综合久久99| 在线精品视频免费播放| 99视频在线精品| 岛国一区二区三区| 国产一区二区三区国产| 久久99国内精品| 免费观看在线综合| 丝瓜av网站精品一区二区| 亚洲国产一区二区三区 | 免费观看在线色综合| 日韩av在线发布| 视频一区二区三区在线| 日韩高清在线一区| 美女精品自拍一二三四| 久久av资源站| 成人午夜碰碰视频| 色综合天天狠狠| 欧美三级电影网站| 欧美一区二区三区四区视频| 日韩欧美在线综合网| 精品国产免费一区二区三区四区 | 久久久午夜精品| 欧美激情一区二区三区蜜桃视频| 日本一区二区三区四区| 亚洲欧美日韩在线| 亚洲大片精品永久免费| 久久精品国产亚洲高清剧情介绍 | 亚洲视频小说图片| 日本不卡123| 成人免费视频一区| 欧美人妇做爰xxxⅹ性高电影| 日韩美女视频在线| 国产精品黄色在线观看| 老司机精品视频一区二区三区| gogo大胆日本视频一区| 欧美精品一二三| 亚洲精品写真福利| 国内精品久久久久影院一蜜桃| 91视频一区二区三区| 日韩午夜av一区| 亚洲一区二区视频在线观看| 精品一区二区三区香蕉蜜桃| 欧美在线观看18| 亚洲日本中文字幕区| 免费高清视频精品| 欧美日韩中文另类| 亚洲精品水蜜桃| 99精品偷自拍| 中文字幕中文乱码欧美一区二区| 国产呦精品一区二区三区网站| 精品污污网站免费看| 一区二区三区四区国产精品| 国产不卡高清在线观看视频| 欧美大尺度电影在线| 免费成人在线网站| 欧美一区二区三区四区在线观看| 亚洲成人1区2区| 欧美一级片在线| 蜜臀av性久久久久蜜臀aⅴ | 99久免费精品视频在线观看| 久久久天堂av| 成人永久免费视频| 国产精品久久久久久久久久久免费看| 精品亚洲欧美一区| 中文字幕在线不卡一区| 91网站在线播放| 亚洲国产日韩精品| 欧美大片免费久久精品三p| 精品午夜久久福利影院| 国产日产欧美一区二区三区| 五月天亚洲精品| 欧美日韩一区三区四区| 久久97超碰国产精品超碰| 久久免费看少妇高潮| 91福利精品第一导航| 美女尤物国产一区| 综合自拍亚洲综合图不卡区| 欧美色图天堂网| 粉嫩欧美一区二区三区高清影视| 中文字幕一区三区| 欧美裸体一区二区三区| 精品国精品自拍自在线| 久久无码av三级| 国产专区综合网| 亚洲欧洲色图综合| 8x福利精品第一导航| 99免费精品视频| 国产另类ts人妖一区二区| 亚洲国产cao| 国产精品免费久久| 日韩欧美一级片| 欧美日韩综合不卡| 成人动漫一区二区三区| 日韩电影一区二区三区四区| **网站欧美大片在线观看| 久久久久亚洲蜜桃| 欧美一区三区四区| 777午夜精品免费视频| 99久久久国产精品| 国产成人午夜精品5599| 免费观看久久久4p| 久久精品噜噜噜成人av农村| 午夜a成v人精品| 亚洲综合一二三区| 伊人色综合久久天天| 国产精品久久久久久久久果冻传媒| 日韩欧美激情一区| 精品国产91亚洲一区二区三区婷婷| 欧美日韩一本到| 91捆绑美女网站| 欧美日韩在线一区二区| 欧美色精品天天在线观看视频| 欧美日韩一区二区在线观看视频| 一本一本大道香蕉久在线精品| 色婷婷综合久久久中文一区二区| 国产69精品久久久久毛片| eeuss鲁片一区二区三区| caoporen国产精品视频| 在线观看中文字幕不卡| 欧美疯狂做受xxxx富婆| 久久嫩草精品久久久精品一| 国产午夜久久久久| 亚洲一区二区三区三| 捆绑调教美女网站视频一区| 国产福利一区在线观看| 91成人网在线| 欧美激情综合网| 亚洲欧美电影一区二区| 亚洲123区在线观看| 国产成人午夜99999| 欧美精三区欧美精三区| 国产日本亚洲高清| 日本不卡一二三| 色www精品视频在线观看| 欧美电影免费观看高清完整版在线观看| 精品国产亚洲一区二区三区在线观看 | 国产精品久久久久久久第一福利| 一区二区三区在线视频免费| 免费视频最近日韩| 欧美日韩日日夜夜| 中文字幕一区二区三区精华液 | 91成人免费网站| 国产精品色呦呦| 国产一区二区三区在线观看免费视频| 在线精品观看国产| 亚洲女爱视频在线| 懂色av中文一区二区三区| 精品国产一区二区三区久久久蜜月| 一区二区三区四区亚洲| 91免费看`日韩一区二区| 欧美国产亚洲另类动漫| 国产在线乱码一区二区三区| 3d动漫精品啪啪| 久久精品国产色蜜蜜麻豆| 91精品国产91热久久久做人人| 综合精品久久久| 欧美亚洲免费在线一区| 亚洲国产美女搞黄色| 欧美日韩综合一区| 舔着乳尖日韩一区| 日韩欧美国产高清|