TEST_F(ConfigTest, config_section_end) { config_t *config = config_new(CONFIG_FILE); const config_section_node_t * section = config_section_begin(config); section = config_section_next(section); section = config_section_next(section); EXPECT_EQ(section, config_section_end(config)); config_free(config); }
void btc_config_save(void) { assert(config != NULL); // Garbage collection process: the config file accumulates // cached information about remote devices during regular // inquiry scans. We remove some of these junk entries // so the file doesn't grow indefinitely. We have to take care // to make sure we don't remove information about bonded // devices (hence the check for link keys). static const size_t CACHE_MAX = 256; const char *keys[CACHE_MAX]; size_t num_keys = 0; size_t total_candidates = 0; osi_mutex_lock(&lock, OSI_MUTEX_MAX_TIMEOUT); for (const config_section_node_t *snode = config_section_begin(config); snode != config_section_end(config); snode = config_section_next(snode)) { const char *section = config_section_name(snode); if (!string_is_bdaddr(section)) { continue; } if (config_has_key(config, section, "LinkKey") || config_has_key(config, section, "LE_KEY_PENC") || config_has_key(config, section, "LE_KEY_PID") || config_has_key(config, section, "LE_KEY_PCSRK") || config_has_key(config, section, "LE_KEY_LENC") || config_has_key(config, section, "LE_KEY_LCSRK")) { continue; } if (num_keys < CACHE_MAX) { keys[num_keys++] = section; } ++total_candidates; } if (total_candidates > CACHE_MAX * 2) while (num_keys > 0) { config_remove_section(config, keys[--num_keys]); } config_save(config, CONFIG_FILE_PATH); osi_mutex_unlock(&lock); }
const btif_config_section_iter_t *btif_config_section_end(void) { assert(config != NULL); return (const btif_config_section_iter_t *)config_section_end(config); }