Lines Matching defs:pH

35 void sqlite3HashClear(Hash *pH){
38 assert( pH!=0 );
39 elem = pH->first;
40 pH->first = 0;
41 sqlite3_free(pH->ht);
42 pH->ht = 0;
43 pH->htsize = 0;
49 pH->count = 0;
66 /* Link pNew element into the hash table pH. If pEntry!=0 then also
70 Hash *pH, /* The complete hash table */
86 else { pH->first = pNew; }
89 pNew->next = pH->first;
90 if( pH->first ){ pH->first->prev = pNew; }
92 pH->first = pNew;
103 static int rehash(Hash *pH, unsigned int new_size){
111 if( new_size==pH->htsize ) return 0;
123 sqlite3_free(pH->ht);
124 pH->ht = new_ht;
125 pH->htsize = new_size = sqlite3MallocSize(new_ht)/sizeof(struct _ht);
127 for(elem=pH->first, pH->first=0; elem; elem = next_elem){
130 insertElement(pH, &new_ht[h], elem);
140 const Hash *pH, /* The pH to be searched */
148 if( pH->ht ){
149 struct _ht *pEntry = &pH->ht[h];
153 elem = pH->first;
154 count = pH->count;
169 Hash *pH, /* The pH containing "elem" */
170 HashElem* elem, /* The element to be removed from the pH */
177 pH->first = elem->next;
182 if( pH->ht ){
183 pEntry = &pH->ht[h];
191 pH->count--;
192 if( pH->count<=0 ){
193 assert( pH->first==0 );
194 assert( pH->count==0 );
195 sqlite3HashClear(pH);
199 /* Attempt to locate an element of the hash table pH with a key
203 void *sqlite3HashFind(const Hash *pH, const char *pKey, int nKey){
207 assert( pH!=0 );
210 if( pH->ht ){
211 h = strHash(pKey, nKey) % pH->htsize;
215 elem = findElementGivenHash(pH, pKey, nKey, h);
219 /* Insert an element into the hash table pH. The key is pKey,nKey
233 void *sqlite3HashInsert(Hash *pH, const char *pKey, int nKey, void *data){
236 HashElem *new_elem; /* New element added to the pH */
238 assert( pH!=0 );
241 if( pH->htsize ){
242 h = strHash(pKey, nKey) % pH->htsize;
246 elem = findElementGivenHash(pH,pKey,nKey,h);
250 removeElementGivenHash(pH,elem,h);
264 pH->count++;
265 if( pH->count>=10 && pH->count > 2*pH->htsize ){
266 if( rehash(pH, pH->count*2) ){
267 assert( pH->htsize>0 );
268 h = strHash(pKey, nKey) % pH->htsize;
271 if( pH->ht ){
272 insertElement(pH, &pH->ht[h], new_elem);
274 insertElement(pH, 0, new_elem);