Lines Matching refs:pH
35 void sqlite3HashClear(Hash *pH){ in sqlite3HashClear() argument
38 assert( pH!=0 ); in sqlite3HashClear()
39 elem = pH->first; in sqlite3HashClear()
40 pH->first = 0; in sqlite3HashClear()
41 sqlite3_free(pH->ht); in sqlite3HashClear()
42 pH->ht = 0; in sqlite3HashClear()
43 pH->htsize = 0; in sqlite3HashClear()
49 pH->count = 0; in sqlite3HashClear()
73 Hash *pH, /* The complete hash table */ in insertElement() argument
89 else { pH->first = pNew; } in insertElement()
92 pNew->next = pH->first; in insertElement()
93 if( pH->first ){ pH->first->prev = pNew; } in insertElement()
95 pH->first = pNew; in insertElement()
106 static int rehash(Hash *pH, unsigned int new_size){ in rehash() argument
114 if( new_size==pH->htsize ) return 0; in rehash()
130 sqlite3_free(pH->ht); in rehash()
131 pH->ht = new_ht; in rehash()
132 pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht); in rehash()
134 for(elem=pH->first, pH->first=0; elem; elem = next_elem){ in rehash()
137 insertElement(pH, &new_ht[h], elem); in rehash()
148 const Hash *pH, /* The pH to be searched */ in findElementWithHash() argument
157 if( pH->ht ){ /*OPTIMIZATION-IF-TRUE*/ in findElementWithHash()
159 h = strHash(pKey) % pH->htsize; in findElementWithHash()
160 pEntry = &pH->ht[h]; in findElementWithHash()
165 elem = pH->first; in findElementWithHash()
166 count = pH->count; in findElementWithHash()
183 Hash *pH, /* The pH containing "elem" */ in removeElementGivenHash() argument
191 pH->first = elem->next; in removeElementGivenHash()
196 if( pH->ht ){ in removeElementGivenHash()
197 pEntry = &pH->ht[h]; in removeElementGivenHash()
205 pH->count--; in removeElementGivenHash()
206 if( pH->count==0 ){ in removeElementGivenHash()
207 assert( pH->first==0 ); in removeElementGivenHash()
208 assert( pH->count==0 ); in removeElementGivenHash()
209 sqlite3HashClear(pH); in removeElementGivenHash()
217 void *sqlite3HashFind(const Hash *pH, const char *pKey){ in sqlite3HashFind() argument
218 assert( pH!=0 ); in sqlite3HashFind()
220 return findElementWithHash(pH, pKey, 0)->data; in sqlite3HashFind()
237 void *sqlite3HashInsert(Hash *pH, const char *pKey, void *data){ in sqlite3HashInsert() argument
242 assert( pH!=0 ); in sqlite3HashInsert()
244 elem = findElementWithHash(pH,pKey,&h); in sqlite3HashInsert()
248 removeElementGivenHash(pH,elem,h); in sqlite3HashInsert()
260 pH->count++; in sqlite3HashInsert()
261 if( pH->count>=10 && pH->count > 2*pH->htsize ){ in sqlite3HashInsert()
262 if( rehash(pH, pH->count*2) ){ in sqlite3HashInsert()
263 assert( pH->htsize>0 ); in sqlite3HashInsert()
264 h = strHash(pKey) % pH->htsize; in sqlite3HashInsert()
267 insertElement(pH, pH->ht ? &pH->ht[h] : 0, new_elem); in sqlite3HashInsert()