void menu_software_list::append_software_entry(const software_info &swinfo) { entry_info entry; bool entry_updated = false; // check if at least one of the parts has the correct interface and add a menu entry only in this case for (const software_part &swpart : swinfo.parts()) { if (swpart.matches_interface(m_interface) && m_swlist->is_compatible(swpart) == SOFTWARE_IS_COMPATIBLE) { entry_updated = true; entry.short_name.assign(swinfo.shortname()); entry.long_name.assign(swinfo.longname()); break; } } // skip this if no new entry has been allocated (e.g. if the software has no matching interface for this image device) if (entry_updated) { // find the end of the list auto iter = m_entrylist.begin(); while (iter != m_entrylist.end() && compare_entries(entry, *iter, m_ordered_by_shortname) >= 0) ++iter; m_entrylist.emplace(iter, std::move(entry)); } }
/* * @Returns > 0 if there has changed an entry * or zero if tables are the same */ int compare_tables (rip_table_t * table, rip_table_t * table_aux, int num_entries, ipv4_addr_t src){ //UPDATE METRICS FOR INCOMING TABLE //lo que solo tiene sentido si el mensaje viene //de una maquina que no es la nuestra if( memcmp(ipv4_hostaddr, src, sizeof(ipv4_addr_t)) != 0) { update_metrics (table_aux, num_entries); } //variable used for checking if we have modified the table int changes = 0; int i; for (i=0; i<num_entries; i++){ changes += compare_entries (table, table_aux->routes[i], src); } return changes; }
ui_menu_file_selector::file_selector_entry *ui_menu_file_selector::append_entry( file_selector_entry_type entry_type, const char *entry_basename, const char *entry_fullpath) { file_selector_entry *entry; file_selector_entry **entryptr; // allocate a new entry entry = (file_selector_entry *) m_pool_alloc(sizeof(*entry)); memset(entry, 0, sizeof(*entry)); entry->type = entry_type; entry->basename = (entry_basename != NULL) ? pool_strdup(entry_basename) : entry_basename; entry->fullpath = (entry_fullpath != NULL) ? pool_strdup(entry_fullpath) : entry_fullpath; // find the end of the list entryptr = &m_entrylist; while ((*entryptr != NULL) && (compare_entries(entry, *entryptr) >= 0)) entryptr = &(*entryptr)->next; // insert the entry entry->next = *entryptr; *entryptr = entry; return entry; }
menu_software_list::entry_info *menu_software_list::append_software_entry(const software_info &swinfo) { entry_info *entry = nullptr; entry_info **entryptr; bool entry_updated = FALSE; // check if at least one of the parts has the correct interface and add a menu entry only in this case for (const software_part &swpart : swinfo.parts()) { if (swpart.matches_interface(m_interface) && swpart.is_compatible(*m_swlist) == SOFTWARE_IS_COMPATIBLE) { entry_updated = TRUE; // allocate a new entry entry = (entry_info *) m_pool_alloc(sizeof(*entry)); memset(entry, 0, sizeof(*entry)); entry->short_name = pool_strdup(swinfo.shortname()); entry->long_name = pool_strdup(swinfo.longname()); break; } } // skip this if no new entry has been allocated (e.g. if the software has no matching interface for this image device) if (entry_updated) { // find the end of the list entryptr = &m_entrylist; while ((*entryptr != nullptr) && (compare_entries(entry, *entryptr, m_ordered_by_shortname) >= 0)) entryptr = &(*entryptr)->next; // insert the entry entry->next = *entryptr; *entryptr = entry; } return entry; }