drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 1 | /* |
| 2 | ** 2001 September 22 |
| 3 | ** |
| 4 | ** The author disclaims copyright to this source code. In place of |
| 5 | ** a legal notice, here is a blessing: |
| 6 | ** |
| 7 | ** May you do good and not evil. |
| 8 | ** May you find forgiveness for yourself and forgive others. |
| 9 | ** May you share freely, never taking more than you give. |
| 10 | ** |
| 11 | ************************************************************************* |
| 12 | ** This is the implementation of generic hash-tables |
| 13 | ** used in SQLite. |
| 14 | ** |
drh | a83ccca | 2009-04-28 13:01:09 +0000 | [diff] [blame] | 15 | ** $Id: hash.c,v 1.34 2009/04/28 13:01:09 drh Exp $ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 16 | */ |
| 17 | #include "sqliteInt.h" |
| 18 | #include <assert.h> |
| 19 | |
| 20 | /* Turn bulk memory into a hash table object by initializing the |
| 21 | ** fields of the Hash structure. |
drh | aacc543 | 2002-01-06 17:07:40 +0000 | [diff] [blame] | 22 | ** |
drh | 76d7f8b | 2004-06-30 22:43:21 +0000 | [diff] [blame] | 23 | ** "pNew" is a pointer to the hash table that is to be initialized. |
drh | 1b67f3c | 2008-10-10 17:41:28 +0000 | [diff] [blame] | 24 | ** "copyKey" is true if the hash table should make its own private |
| 25 | ** copy of keys and false if it should just use the supplied pointer. |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 26 | */ |
drh | 1b67f3c | 2008-10-10 17:41:28 +0000 | [diff] [blame] | 27 | void sqlite3HashInit(Hash *pNew, int copyKey){ |
drh | 76d7f8b | 2004-06-30 22:43:21 +0000 | [diff] [blame] | 28 | assert( pNew!=0 ); |
drh | 1b67f3c | 2008-10-10 17:41:28 +0000 | [diff] [blame] | 29 | pNew->copyKey = copyKey!=0; |
drh | 76d7f8b | 2004-06-30 22:43:21 +0000 | [diff] [blame] | 30 | pNew->first = 0; |
| 31 | pNew->count = 0; |
| 32 | pNew->htsize = 0; |
| 33 | pNew->ht = 0; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | /* Remove all entries from a hash table. Reclaim all memory. |
drh | aacc543 | 2002-01-06 17:07:40 +0000 | [diff] [blame] | 37 | ** Call this routine to delete a hash table or to reset a hash table |
| 38 | ** to the empty state. |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 39 | */ |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 40 | void sqlite3HashClear(Hash *pH){ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 41 | HashElem *elem; /* For looping over all elements of the table */ |
| 42 | |
| 43 | assert( pH!=0 ); |
| 44 | elem = pH->first; |
| 45 | pH->first = 0; |
drh | 41eb9e9 | 2008-04-02 18:33:07 +0000 | [diff] [blame] | 46 | sqlite3_free(pH->ht); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 47 | pH->ht = 0; |
| 48 | pH->htsize = 0; |
| 49 | while( elem ){ |
| 50 | HashElem *next_elem = elem->next; |
drh | e2f02ba | 2009-01-09 01:12:27 +0000 | [diff] [blame] | 51 | if( pH->copyKey ){ |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 52 | sqlite3_free(elem->pKey); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 53 | } |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 54 | sqlite3_free(elem); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 55 | elem = next_elem; |
| 56 | } |
| 57 | pH->count = 0; |
| 58 | } |
| 59 | |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 60 | /* |
| 61 | ** Hash and comparison functions when the mode is SQLITE_HASH_STRING |
| 62 | */ |
| 63 | static int strHash(const void *pKey, int nKey){ |
danielk1977 | 52a83fb | 2005-01-31 12:56:44 +0000 | [diff] [blame] | 64 | const char *z = (const char *)pKey; |
| 65 | int h = 0; |
drh | a83ccca | 2009-04-28 13:01:09 +0000 | [diff] [blame] | 66 | assert( nKey>0 ); |
danielk1977 | 52a83fb | 2005-01-31 12:56:44 +0000 | [diff] [blame] | 67 | while( nKey > 0 ){ |
| 68 | h = (h<<3) ^ h ^ sqlite3UpperToLower[(unsigned char)*z++]; |
| 69 | nKey--; |
| 70 | } |
| 71 | return h & 0x7fffffff; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 72 | } |
| 73 | static int strCompare(const void *pKey1, int n1, const void *pKey2, int n2){ |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 74 | if( n1!=n2 ) return 1; |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 75 | return sqlite3StrNICmp((const char*)pKey1,(const char*)pKey2,n1); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 76 | } |
| 77 | |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 78 | |
| 79 | /* Link an element into the hash table |
| 80 | */ |
| 81 | static void insertElement( |
| 82 | Hash *pH, /* The complete hash table */ |
| 83 | struct _ht *pEntry, /* The entry into which pNew is inserted */ |
| 84 | HashElem *pNew /* The element to be inserted */ |
| 85 | ){ |
| 86 | HashElem *pHead; /* First element already in pEntry */ |
| 87 | pHead = pEntry->chain; |
| 88 | if( pHead ){ |
| 89 | pNew->next = pHead; |
| 90 | pNew->prev = pHead->prev; |
| 91 | if( pHead->prev ){ pHead->prev->next = pNew; } |
| 92 | else { pH->first = pNew; } |
| 93 | pHead->prev = pNew; |
| 94 | }else{ |
| 95 | pNew->next = pH->first; |
| 96 | if( pH->first ){ pH->first->prev = pNew; } |
| 97 | pNew->prev = 0; |
| 98 | pH->first = pNew; |
| 99 | } |
| 100 | pEntry->count++; |
| 101 | pEntry->chain = pNew; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 102 | } |
| 103 | |
| 104 | |
drh | aacc543 | 2002-01-06 17:07:40 +0000 | [diff] [blame] | 105 | /* Resize the hash table so that it cantains "new_size" buckets. |
| 106 | ** "new_size" must be a power of 2. The hash table might fail |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 107 | ** to resize if sqlite3_malloc() fails. |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 108 | */ |
| 109 | static void rehash(Hash *pH, int new_size){ |
| 110 | struct _ht *new_ht; /* The new hash table */ |
| 111 | HashElem *elem, *next_elem; /* For looping over existing elements */ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 112 | |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 113 | #ifdef SQLITE_MALLOC_SOFT_LIMIT |
| 114 | if( new_size*sizeof(struct _ht)>SQLITE_MALLOC_SOFT_LIMIT ){ |
| 115 | new_size = SQLITE_MALLOC_SOFT_LIMIT/sizeof(struct _ht); |
| 116 | } |
| 117 | if( new_size==pH->htsize ) return; |
| 118 | #endif |
danielk1977 | a1644fd | 2007-08-29 12:31:25 +0000 | [diff] [blame] | 119 | |
| 120 | /* There is a call to sqlite3_malloc() inside rehash(). If there is |
| 121 | ** already an allocation at pH->ht, then if this malloc() fails it |
| 122 | ** is benign (since failing to resize a hash table is a performance |
| 123 | ** hit only, not a fatal error). |
| 124 | */ |
danielk1977 | 2d1d86f | 2008-06-20 14:59:51 +0000 | [diff] [blame] | 125 | if( pH->htsize>0 ) sqlite3BeginBenignMalloc(); |
danielk1977 | 1e53695 | 2007-08-16 10:09:01 +0000 | [diff] [blame] | 126 | new_ht = (struct _ht *)sqlite3MallocZero( new_size*sizeof(struct _ht) ); |
danielk1977 | 2d1d86f | 2008-06-20 14:59:51 +0000 | [diff] [blame] | 127 | if( pH->htsize>0 ) sqlite3EndBenignMalloc(); |
drh | 643167f | 2008-01-22 21:30:53 +0000 | [diff] [blame] | 128 | |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 129 | if( new_ht==0 ) return; |
drh | 41eb9e9 | 2008-04-02 18:33:07 +0000 | [diff] [blame] | 130 | sqlite3_free(pH->ht); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 131 | pH->ht = new_ht; |
| 132 | pH->htsize = new_size; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 133 | for(elem=pH->first, pH->first=0; elem; elem = next_elem){ |
drh | 1b67f3c | 2008-10-10 17:41:28 +0000 | [diff] [blame] | 134 | int h = strHash(elem->pKey, elem->nKey) & (new_size-1); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 135 | next_elem = elem->next; |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 136 | insertElement(pH, &new_ht[h], elem); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 137 | } |
| 138 | } |
| 139 | |
| 140 | /* This function (for internal use only) locates an element in an |
drh | aacc543 | 2002-01-06 17:07:40 +0000 | [diff] [blame] | 141 | ** hash table that matches the given key. The hash for this key has |
| 142 | ** already been computed and is passed as the 4th parameter. |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 143 | */ |
| 144 | static HashElem *findElementGivenHash( |
| 145 | const Hash *pH, /* The pH to be searched */ |
| 146 | const void *pKey, /* The key we are searching for */ |
| 147 | int nKey, |
| 148 | int h /* The hash for this key. */ |
| 149 | ){ |
| 150 | HashElem *elem; /* Used to loop thru the element list */ |
| 151 | int count; /* Number of elements left to test */ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 152 | |
| 153 | if( pH->ht ){ |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 154 | struct _ht *pEntry = &pH->ht[h]; |
| 155 | elem = pEntry->chain; |
| 156 | count = pEntry->count; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 157 | while( count-- && elem ){ |
drh | 1b67f3c | 2008-10-10 17:41:28 +0000 | [diff] [blame] | 158 | if( strCompare(elem->pKey,elem->nKey,pKey,nKey)==0 ){ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 159 | return elem; |
| 160 | } |
| 161 | elem = elem->next; |
| 162 | } |
| 163 | } |
| 164 | return 0; |
| 165 | } |
| 166 | |
drh | 81a20f2 | 2001-10-12 17:30:04 +0000 | [diff] [blame] | 167 | /* Remove a single entry from the hash table given a pointer to that |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 168 | ** element and a hash on the element's key. |
| 169 | */ |
| 170 | static void removeElementGivenHash( |
| 171 | Hash *pH, /* The pH containing "elem" */ |
| 172 | HashElem* elem, /* The element to be removed from the pH */ |
drh | aacc543 | 2002-01-06 17:07:40 +0000 | [diff] [blame] | 173 | int h /* Hash value for the element */ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 174 | ){ |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 175 | struct _ht *pEntry; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 176 | if( elem->prev ){ |
| 177 | elem->prev->next = elem->next; |
| 178 | }else{ |
| 179 | pH->first = elem->next; |
| 180 | } |
| 181 | if( elem->next ){ |
| 182 | elem->next->prev = elem->prev; |
| 183 | } |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 184 | pEntry = &pH->ht[h]; |
| 185 | if( pEntry->chain==elem ){ |
| 186 | pEntry->chain = elem->next; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 187 | } |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 188 | pEntry->count--; |
| 189 | if( pEntry->count<=0 ){ |
| 190 | pEntry->chain = 0; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 191 | } |
drh | 93553ad | 2007-03-31 03:59:23 +0000 | [diff] [blame] | 192 | if( pH->copyKey ){ |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 193 | sqlite3_free(elem->pKey); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 194 | } |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 195 | sqlite3_free( elem ); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 196 | pH->count--; |
drh | 762e584 | 2005-10-03 15:11:08 +0000 | [diff] [blame] | 197 | if( pH->count<=0 ){ |
| 198 | assert( pH->first==0 ); |
| 199 | assert( pH->count==0 ); |
| 200 | sqlite3HashClear(pH); |
| 201 | } |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 202 | } |
| 203 | |
drh | aacc543 | 2002-01-06 17:07:40 +0000 | [diff] [blame] | 204 | /* Attempt to locate an element of the hash table pH with a key |
danielk1977 | 7c836f0 | 2007-09-04 14:31:47 +0000 | [diff] [blame] | 205 | ** that matches pKey,nKey. Return a pointer to the corresponding |
| 206 | ** HashElem structure for this element if it is found, or NULL |
| 207 | ** otherwise. |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 208 | */ |
danielk1977 | 7c836f0 | 2007-09-04 14:31:47 +0000 | [diff] [blame] | 209 | HashElem *sqlite3HashFindElem(const Hash *pH, const void *pKey, int nKey){ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 210 | int h; /* A hash on key */ |
| 211 | HashElem *elem; /* The element that matches key */ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 212 | |
| 213 | if( pH==0 || pH->ht==0 ) return 0; |
drh | 1b67f3c | 2008-10-10 17:41:28 +0000 | [diff] [blame] | 214 | h = strHash(pKey,nKey); |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 215 | elem = findElementGivenHash(pH,pKey,nKey, h % pH->htsize); |
danielk1977 | 7c836f0 | 2007-09-04 14:31:47 +0000 | [diff] [blame] | 216 | return elem; |
| 217 | } |
| 218 | |
| 219 | /* Attempt to locate an element of the hash table pH with a key |
| 220 | ** that matches pKey,nKey. Return the data for this element if it is |
| 221 | ** found, or NULL if there is no match. |
| 222 | */ |
| 223 | void *sqlite3HashFind(const Hash *pH, const void *pKey, int nKey){ |
| 224 | HashElem *elem; /* The element that matches key */ |
| 225 | elem = sqlite3HashFindElem(pH, pKey, nKey); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 226 | return elem ? elem->data : 0; |
| 227 | } |
| 228 | |
drh | 81a20f2 | 2001-10-12 17:30:04 +0000 | [diff] [blame] | 229 | /* Insert an element into the hash table pH. The key is pKey,nKey |
| 230 | ** and the data is "data". |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 231 | ** |
drh | 81a20f2 | 2001-10-12 17:30:04 +0000 | [diff] [blame] | 232 | ** If no element exists with a matching key, then a new |
| 233 | ** element is created. A copy of the key is made if the copyKey |
| 234 | ** flag is set. NULL is returned. |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 235 | ** |
| 236 | ** If another element already exists with the same key, then the |
| 237 | ** new data replaces the old data and the old data is returned. |
drh | 6d4abfb | 2001-10-22 02:58:08 +0000 | [diff] [blame] | 238 | ** The key is not copied in this instance. If a malloc fails, then |
drh | aacc543 | 2002-01-06 17:07:40 +0000 | [diff] [blame] | 239 | ** the new data is returned and the hash table is unchanged. |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 240 | ** |
| 241 | ** If the "data" parameter to this function is NULL, then the |
drh | 81a20f2 | 2001-10-12 17:30:04 +0000 | [diff] [blame] | 242 | ** element corresponding to "key" is removed from the hash table. |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 243 | */ |
danielk1977 | 4adee20 | 2004-05-08 08:23:19 +0000 | [diff] [blame] | 244 | void *sqlite3HashInsert(Hash *pH, const void *pKey, int nKey, void *data){ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 245 | int hraw; /* Raw hash value of the key */ |
| 246 | int h; /* the hash of the key modulo hash table size */ |
| 247 | HashElem *elem; /* Used to loop thru the element list */ |
| 248 | HashElem *new_elem; /* New element added to the pH */ |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 249 | |
| 250 | assert( pH!=0 ); |
drh | 1b67f3c | 2008-10-10 17:41:28 +0000 | [diff] [blame] | 251 | hraw = strHash(pKey, nKey); |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 252 | if( pH->htsize ){ |
| 253 | h = hraw % pH->htsize; |
| 254 | elem = findElementGivenHash(pH,pKey,nKey,h); |
| 255 | if( elem ){ |
| 256 | void *old_data = elem->data; |
| 257 | if( data==0 ){ |
| 258 | removeElementGivenHash(pH,elem,h); |
| 259 | }else{ |
| 260 | elem->data = data; |
| 261 | if( !pH->copyKey ){ |
| 262 | elem->pKey = (void *)pKey; |
| 263 | } |
| 264 | assert(nKey==elem->nKey); |
danielk1977 | cd2543b | 2007-09-03 15:03:20 +0000 | [diff] [blame] | 265 | } |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 266 | return old_data; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 267 | } |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 268 | } |
| 269 | if( data==0 ) return 0; |
drh | e5ae573 | 2008-06-15 02:51:47 +0000 | [diff] [blame] | 270 | new_elem = (HashElem*)sqlite3Malloc( sizeof(HashElem) ); |
drh | 6d4abfb | 2001-10-22 02:58:08 +0000 | [diff] [blame] | 271 | if( new_elem==0 ) return data; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 272 | if( pH->copyKey && pKey!=0 ){ |
drh | e5ae573 | 2008-06-15 02:51:47 +0000 | [diff] [blame] | 273 | new_elem->pKey = sqlite3Malloc( nKey ); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 274 | if( new_elem->pKey==0 ){ |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 275 | sqlite3_free(new_elem); |
drh | 6d4abfb | 2001-10-22 02:58:08 +0000 | [diff] [blame] | 276 | return data; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 277 | } |
| 278 | memcpy((void*)new_elem->pKey, pKey, nKey); |
| 279 | }else{ |
drh | 2ce1a6e | 2002-05-21 23:44:30 +0000 | [diff] [blame] | 280 | new_elem->pKey = (void*)pKey; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 281 | } |
| 282 | new_elem->nKey = nKey; |
| 283 | pH->count++; |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 284 | if( pH->htsize==0 ){ |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 285 | rehash(pH, 128/sizeof(pH->ht[0])); |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 286 | if( pH->htsize==0 ){ |
| 287 | pH->count = 0; |
drh | 93553ad | 2007-03-31 03:59:23 +0000 | [diff] [blame] | 288 | if( pH->copyKey ){ |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 289 | sqlite3_free(new_elem->pKey); |
drh | 93553ad | 2007-03-31 03:59:23 +0000 | [diff] [blame] | 290 | } |
drh | 1743575 | 2007-08-16 04:30:38 +0000 | [diff] [blame] | 291 | sqlite3_free(new_elem); |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 292 | return data; |
| 293 | } |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 294 | } |
| 295 | if( pH->count > pH->htsize ){ |
| 296 | rehash(pH,pH->htsize*2); |
| 297 | } |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 298 | assert( pH->htsize>0 ); |
drh | eee4c8c | 2008-02-18 22:24:57 +0000 | [diff] [blame] | 299 | h = hraw % pH->htsize; |
drh | e8cf2ca | 2004-08-20 14:08:50 +0000 | [diff] [blame] | 300 | insertElement(pH, &pH->ht[h], new_elem); |
drh | beae319 | 2001-09-22 18:12:08 +0000 | [diff] [blame] | 301 | new_elem->data = data; |
| 302 | return 0; |
| 303 | } |