Destroy an entire dictionary */
| 550 | |
| 551 | /* Destroy an entire dictionary */ |
| 552 | static int _dictClear(dict *d, int htidx, void(callback)(dict*)) { |
| 553 | unsigned long i; |
| 554 | |
| 555 | /* Free all the elements */ |
| 556 | for (i = 0; i < DICTHT_SIZE(d->ht_size_exp[htidx]) && d->ht_used[htidx] > 0; i++) { |
| 557 | dictEntry *he, *nextHe; |
| 558 | |
| 559 | if (callback && (i & 65535) == 0) callback(d); |
| 560 | |
| 561 | if ((he = d->ht_table[htidx][i]) == NULL) continue; |
| 562 | while(he) { |
| 563 | nextHe = he->next; |
| 564 | dictFreeKey(d, he); |
| 565 | dictFreeVal(d, he); |
| 566 | free(he); |
| 567 | d->ht_used[htidx]--; |
| 568 | he = nextHe; |
| 569 | } |
| 570 | } |
| 571 | /* Free the table and the allocated cache structure */ |
| 572 | free(d->ht_table[htidx]); |
| 573 | /* Re-initialize the table */ |
| 574 | _dictReset(d, htidx); |
| 575 | return DICT_OK; /* never fails */ |
| 576 | } |
| 577 | |
| 578 | /* Clear & Release the hash table */ |
| 579 | void HashTableRelease(dict *d) |
no test coverage detected