MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / dictDelete

Function dictDelete

deps/hiredis/dict.c:194–222  ·  view source on GitHub ↗

Search and remove an element */

Source from the content-addressed store, hash-verified

192
193/* Search and remove an element */
194static int dictDelete(dict *ht, const void *key) {
195 unsigned int h;
196 dictEntry *de, *prevde;
197
198 if (ht->size == 0)
199 return DICT_ERR;
200 h = dictHashKey(ht, key) & ht->sizemask;
201 de = ht->table[h];
202
203 prevde = NULL;
204 while(de) {
205 if (dictCompareHashKeys(ht,key,de->key)) {
206 /* Unlink the element from the list */
207 if (prevde)
208 prevde->next = de->next;
209 else
210 ht->table[h] = de->next;
211
212 dictFreeEntryKey(ht,de);
213 dictFreeEntryVal(ht,de);
214 hi_free(de);
215 ht->used--;
216 return DICT_OK;
217 }
218 prevde = de;
219 de = de->next;
220 }
221 return DICT_ERR; /* not found */
222}
223
224/* Destroy an entire hash table */
225static int _dictClear(dict *ht) {

Callers 1

Calls 1

hi_freeFunction · 0.70

Tested by

no test coverage detected