| 235 | /* debug_htable_delete - delete one entry */ |
| 236 | |
| 237 | int debug_htable_delete(DEBUG_HTABLE *table, const char *key, void (*free_fn) (char *)) |
| 238 | { |
| 239 | if (table && key) { |
| 240 | DEBUG_HTABLE_INFO *ht; |
| 241 | unsigned n = table->hash_fn(key, strlen(key)); |
| 242 | DEBUG_HTABLE_INFO **h; |
| 243 | |
| 244 | n = n % table->size; |
| 245 | |
| 246 | h = table->data + n; |
| 247 | for (ht = *h; ht; ht = ht->next) { |
| 248 | if (STREQ(key, ht->key)) { |
| 249 | if (ht->next) |
| 250 | ht->next->prev = ht->prev; |
| 251 | if (ht->prev) |
| 252 | ht->prev->next = ht->next; |
| 253 | else |
| 254 | *h = ht->next; |
| 255 | table->used--; |
| 256 | FREE(ht->key); |
| 257 | if (free_fn && ht->value) |
| 258 | (*free_fn) (ht->value); |
| 259 | FREE(ht); |
| 260 | return(0); |
| 261 | } |
| 262 | } |
| 263 | } |
| 264 | |
| 265 | return(-1); |
| 266 | } |
| 267 | |
| 268 | /* debug_htable_free - destroy hash table */ |
| 269 |
no outgoing calls
no test coverage detected
searching dependent graphs…