MCPcopy Create free account
hub / github.com/RedisGraph/RedisGraph / _dictClear

Function _dictClear

src/util/dict.c:552–576  ·  view source on GitHub ↗

Destroy an entire dictionary */

Source from the content-addressed store, hash-verified

550
551/* Destroy an entire dictionary */
552static 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 */
579void HashTableRelease(dict *d)

Callers 2

HashTableReleaseFunction · 0.85
HashTableEmptyFunction · 0.85

Calls 1

_dictResetFunction · 0.85

Tested by

no test coverage detected