diff --git a/src/actions.cc b/src/actions.cc index e7cd291..dc93a04 100644 --- a/src/actions.cc +++ b/src/actions.cc @@ -47,10 +47,10 @@ action_parse(char *line) void a_Actions_init(void) { - int n = dList_length(prefs.link_actions); + int n = prefs.link_actions.size(); for (int i = 0; i < n; i++) { - char *line = reinterpret_cast< char * >( dList_nth_data(prefs.link_actions, i) ); + char *line = prefs.link_actions.at( i ); if (line) action_parse(line); } diff --git a/src/dialog.cc b/src/dialog.cc index eb3337b..0d79006 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -188,12 +188,12 @@ const char *a_Dialog_input(const char *title, const char *msg) CustChoice2 *ch = new CustChoice2(1*gap,ih+3*gap,180,24); if (!pm) { - int n_it = dList_length(prefs.search_urls); + const int n_it = prefs.search_urls.size(); pm = new Fl_Menu_Item[n_it+1]; memset(pm, '\0', (n_it + 1) * sizeof(Fl_Menu_Item)); for (int i = 0, j = 0; i < n_it; i++) { char *label, *url, *source; - source = (char *)dList_nth_data(prefs.search_urls, i); + source = prefs.search_urls.at( i ).data(); if (!source || a_Misc_parse_search_url(source, &label, &url) < 0) continue; pm[j++].label(FL_NORMAL_LABEL, dStrdup(label)); diff --git a/src/prefs.cc b/src/prefs.cc index 1897810..92a4289 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -81,14 +81,12 @@ void a_Prefs_init(void) prefs.scroll_switches_tabs = TRUE; prefs.scroll_switches_tabs_reverse = FALSE; prefs.no_proxy = PREFS_NO_PROXY; - prefs.link_actions = dList_new(16); prefs.panel_size = P_medium; prefs.parse_embedded_css=TRUE; prefs.save_dir = PREFS_SAVE_DIR; prefs.scroll_step = 100; prefs.scroll_page_overlap = 50; - prefs.search_urls = dList_new(16); - dList_append(prefs.search_urls, dStrdup(PREFS_SEARCH_URL)); + prefs.search_urls.push_back(PREFS_SEARCH_URL); prefs.search_url_idx = 0; prefs.scrollbar_on_left = FALSE; prefs.scrollbar_page_mode = FALSE; @@ -140,9 +138,4 @@ void a_Prefs_init(void) */ void a_Prefs_freeall() { - int i; - - for (i = 0; i < dList_length(prefs.search_urls); ++i) - dFree(dList_nth_data(prefs.search_urls, i)); - dList_free(prefs.search_urls); } diff --git a/src/prefs.hh b/src/prefs.hh index 6030c72..74c8401 100644 --- a/src/prefs.hh +++ b/src/prefs.hh @@ -15,6 +15,9 @@ #include "url.hh" +#include +#include + #ifdef __cplusplus extern "C" { #else @@ -119,7 +122,7 @@ struct DilloPrefs bool scroll_switches_tabs; bool scroll_switches_tabs_reverse; bool search_url_idx; - Dlist *search_urls; + std::vector< std::string > search_urls; std::optional< std::string > save_dir; bool show_msg; bool show_extra_warnings; @@ -127,7 +130,7 @@ struct DilloPrefs int penalty_hyphen, penalty_hyphen_2; int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2; int stretchability_factor; - Dlist *link_actions; + std::vector< char * > link_actions; }; /** Global Data */ diff --git a/src/uicmd.cc b/src/uicmd.cc index 4c35217..67ac1aa 100644 --- a/src/uicmd.cc +++ b/src/uicmd.cc @@ -741,9 +741,9 @@ static std::optional< std::string > UIcmd_find_search_str(const char *str) /* we found a ' ' in str, check whether the first part of str * is a prefix of a search_url label */ - for (p = 0; p < dList_length(prefs.search_urls); p++) { + for (p = 0; p < prefs.search_urls.size(); p++) { const char *search = - (const char *)dList_nth_data(prefs.search_urls, p); + prefs.search_urls.at(p).c_str(); if (search && dStrnAsciiCasecmp(str, search, len) == 0) { prefs.search_url_idx = p; url = UIcmd_make_search_str(str + len + 1); @@ -1164,7 +1164,7 @@ UIcmd_make_search_str(const char *str) { char *l, *u, *c; std::string keys = a_Url_encode_hex_str(str).value_or( "" ); - char *src = (char*)dList_nth_data(prefs.search_urls, prefs.search_url_idx); + char *src = prefs.search_urls.at( prefs.search_url_idx).data(); std::string search_url; /* parse search_url into label and url */