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

Function dictionary_get

utils/iniparser.cc:339–357  ·  view source on GitHub ↗

-------------------------------------------------------------------------*/ @brief Get a value from a dictionary. @param d dictionary object to search. @param key Key to look for in the dictionary. @param def Default value to return if key not found. @return 1 pointer to internally allocated character string. This function locates a key in a dictionary and re

Source from the content-addressed store, hash-verified

337 */
338/*--------------------------------------------------------------------------*/
339static char * dictionary_get(dictionary * d, char * key, char * def)
340{
341 unsigned hash ;
342 int i ;
343
344 hash = dictionary_hash(key);
345 for (i=0 ; i<d->size ; i++) {
346 if (d->key==NULL)
347 continue ;
348 /* Compare hash */
349 if (hash==d->hash[i]) {
350 /* Compare string, to avoid hash collisions */
351 if (!strcmp(key, d->key[i])) {
352 return d->val[i] ;
353 }
354 }
355 }
356 return def ;
357}
358
359
360/*-------------------------------------------------------------------------*/

Callers 1

iniparser_getstringFunction · 0.85

Calls 1

dictionary_hashFunction · 0.85

Tested by

no test coverage detected