void dictionary_destroy(DICTIONARY *dict) { debug(D_DICTIONARY, "Destroying dictionary."); dictionary_write_lock(dict); while(dict->values_index.root) dictionary_name_value_destroy_nolock(dict, (NAME_VALUE *)dict->values_index.root); dictionary_unlock(dict); free(dict); }
int dictionary_del(DICTIONARY *dict, const char *name) { int ret; debug(D_DICTIONARY, "DEL dictionary entry with name '%s'.", name); dictionary_write_lock(dict); NAME_VALUE *nv = dictionary_name_value_index_find_nolock(dict, name, 0); if(unlikely(!nv)) { debug(D_DICTIONARY, "Not found dictionary entry with name '%s'.", name); ret = -1; } else { debug(D_DICTIONARY, "Found dictionary entry with name '%s'.", name); dictionary_name_value_destroy_nolock(dict, nv); ret = 0; } dictionary_unlock(dict); return ret; }