MCPcopy Create free account
hub / github.com/couchbase/forestdb / dictionary_unset

Function dictionary_unset

utils/iniparser.cc:450–481  ·  view source on GitHub ↗

-------------------------------------------------------------------------*/ @brief Delete a key in a dictionary @param d dictionary object to modify. @param key Key to remove. @return void This function deletes a key in a dictionary. Nothing is done if the key cannot be found. */ --------------------------------------------------------------------------*/

Source from the content-addressed store, hash-verified

448 */
449/*--------------------------------------------------------------------------*/
450static void dictionary_unset(dictionary * d, char * key)
451{
452 unsigned hash ;
453 int i ;
454
455 hash = dictionary_hash(key);
456 for (i=0 ; i<d->size ; i++) {
457 if (d->key[i]==NULL)
458 continue ;
459 /* Compare hash */
460 if (hash==d->hash[i]) {
461 /* Compare string, to avoid hash collisions */
462 if (!strcmp(key, d->key[i])) {
463 /* Found key */
464 break ;
465 }
466 }
467 }
468 if (i>=d->size)
469 /* Key not found */
470 return ;
471
472 free(d->key[i]);
473 d->key[i] = NULL ;
474 if (d->val[i]!=NULL) {
475 free(d->val[i]);
476 d->val[i] = NULL ;
477 }
478 d->hash[i] = 0 ;
479 d->n -- ;
480 return ;
481}
482
483
484/*-------------------------------------------------------------------------*/

Callers 1

iniparser_unsetFunction · 0.85

Calls 1

dictionary_hashFunction · 0.85

Tested by

no test coverage detected