* xmlHashFree: * @hash: hash table * @dealloc: deallocator function or NULL * * Free the hash and its contents. The payload is deallocated with * @dealloc if provided. */
| 226 | * @dealloc if provided. |
| 227 | */ |
| 228 | void |
| 229 | xmlHashFree(xmlHashTablePtr hash, xmlHashDeallocator dealloc) { |
| 230 | if (hash == NULL) |
| 231 | return; |
| 232 | |
| 233 | if (hash->table) { |
| 234 | const xmlHashEntry *end = &hash->table[hash->size]; |
| 235 | const xmlHashEntry *entry; |
| 236 | |
| 237 | for (entry = hash->table; entry < end; entry++) { |
| 238 | if (entry->hashValue == 0) |
| 239 | continue; |
| 240 | if ((dealloc != NULL) && (entry->payload != NULL)) |
| 241 | dealloc(entry->payload, entry->key); |
| 242 | if (hash->dict == NULL) { |
| 243 | if (entry->key) |
| 244 | xmlFree(entry->key); |
| 245 | if (entry->key2) |
| 246 | xmlFree(entry->key2); |
| 247 | if (entry->key3) |
| 248 | xmlFree(entry->key3); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | xmlFree(hash->table); |
| 253 | } |
| 254 | |
| 255 | if (hash->dict) |
| 256 | xmlDictFree(hash->dict); |
| 257 | |
| 258 | xmlFree(hash); |
| 259 | } |
| 260 | |
| 261 | /** |
| 262 | * xmlFastStrEqual: |