Lines Matching refs:pH
48 void sqliteHashClear(Hash *pH){ in sqliteHashClear() argument
51 assert( pH!=0 ); in sqliteHashClear()
52 elem = pH->first; in sqliteHashClear()
53 pH->first = 0; in sqliteHashClear()
54 if( pH->ht ) sqliteFree(pH->ht); in sqliteHashClear()
55 pH->ht = 0; in sqliteHashClear()
56 pH->htsize = 0; in sqliteHashClear()
59 if( pH->copyKey && elem->pKey ){ in sqliteHashClear()
65 pH->count = 0; in sqliteHashClear()
165 static void rehash(Hash *pH, int new_size){ in rehash() argument
174 if( pH->ht ) sqliteFree(pH->ht); in rehash()
175 pH->ht = new_ht; in rehash()
176 pH->htsize = new_size; in rehash()
177 xHash = hashFunction(pH->keyClass); in rehash()
178 for(elem=pH->first, pH->first=0; elem; elem = next_elem){ in rehash()
186 else pH->first = elem; in rehash()
189 elem->next = pH->first; in rehash()
190 if( pH->first ) pH->first->prev = elem; in rehash()
192 pH->first = elem; in rehash()
204 const Hash *pH, /* The pH to be searched */ in findElementGivenHash() argument
213 if( pH->ht ){ in findElementGivenHash()
214 elem = pH->ht[h].chain; in findElementGivenHash()
215 count = pH->ht[h].count; in findElementGivenHash()
216 xCompare = compareFunction(pH->keyClass); in findElementGivenHash()
231 Hash *pH, /* The pH containing "elem" */ in removeElementGivenHash() argument
238 pH->first = elem->next; in removeElementGivenHash()
243 if( pH->ht[h].chain==elem ){ in removeElementGivenHash()
244 pH->ht[h].chain = elem->next; in removeElementGivenHash()
246 pH->ht[h].count--; in removeElementGivenHash()
247 if( pH->ht[h].count<=0 ){ in removeElementGivenHash()
248 pH->ht[h].chain = 0; in removeElementGivenHash()
250 if( pH->copyKey && elem->pKey ){ in removeElementGivenHash()
254 pH->count--; in removeElementGivenHash()
261 void *sqliteHashFind(const Hash *pH, const void *pKey, int nKey){ in sqliteHashFind() argument
266 if( pH==0 || pH->ht==0 ) return 0; in sqliteHashFind()
267 xHash = hashFunction(pH->keyClass); in sqliteHashFind()
270 assert( (pH->htsize & (pH->htsize-1))==0 ); in sqliteHashFind()
271 elem = findElementGivenHash(pH,pKey,nKey, h & (pH->htsize-1)); in sqliteHashFind()
290 void *sqliteHashInsert(Hash *pH, const void *pKey, int nKey, void *data){ in sqliteHashInsert() argument
297 assert( pH!=0 ); in sqliteHashInsert()
298 xHash = hashFunction(pH->keyClass); in sqliteHashInsert()
301 assert( (pH->htsize & (pH->htsize-1))==0 ); in sqliteHashInsert()
302 h = hraw & (pH->htsize-1); in sqliteHashInsert()
303 elem = findElementGivenHash(pH,pKey,nKey,h); in sqliteHashInsert()
307 removeElementGivenHash(pH,elem,h); in sqliteHashInsert()
316 if( pH->copyKey && pKey!=0 ){ in sqliteHashInsert()
327 pH->count++; in sqliteHashInsert()
328 if( pH->htsize==0 ) rehash(pH,8); in sqliteHashInsert()
329 if( pH->htsize==0 ){ in sqliteHashInsert()
330 pH->count = 0; in sqliteHashInsert()
334 if( pH->count > pH->htsize ){ in sqliteHashInsert()
335 rehash(pH,pH->htsize*2); in sqliteHashInsert()
337 assert( (pH->htsize & (pH->htsize-1))==0 ); in sqliteHashInsert()
338 h = hraw & (pH->htsize-1); in sqliteHashInsert()
339 elem = pH->ht[h].chain; in sqliteHashInsert()
344 else { pH->first = new_elem; } in sqliteHashInsert()
347 new_elem->next = pH->first; in sqliteHashInsert()
349 if( pH->first ){ pH->first->prev = new_elem; } in sqliteHashInsert()
350 pH->first = new_elem; in sqliteHashInsert()
352 pH->ht[h].count++; in sqliteHashInsert()
353 pH->ht[h].chain = new_elem; in sqliteHashInsert()