Remove dlists in prefs.

I can remove the NOP free function, now.
This commit is contained in:
2026-01-08 06:45:45 -05:00
parent d4e9e37118
commit 6bc26a63ba
5 changed files with 13 additions and 17 deletions
+2 -2
View File
@@ -47,10 +47,10 @@ action_parse(char *line)
void void
a_Actions_init(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++) { 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) if (line)
action_parse(line); action_parse(line);
} }
+2 -2
View File
@@ -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); CustChoice2 *ch = new CustChoice2(1*gap,ih+3*gap,180,24);
if (!pm) { 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]; pm = new Fl_Menu_Item[n_it+1];
memset(pm, '\0', (n_it + 1) * sizeof(Fl_Menu_Item)); memset(pm, '\0', (n_it + 1) * sizeof(Fl_Menu_Item));
for (int i = 0, j = 0; i < n_it; i++) { for (int i = 0, j = 0; i < n_it; i++) {
char *label, *url, *source; 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) if (!source || a_Misc_parse_search_url(source, &label, &url) < 0)
continue; continue;
pm[j++].label(FL_NORMAL_LABEL, dStrdup(label)); pm[j++].label(FL_NORMAL_LABEL, dStrdup(label));
+1 -8
View File
@@ -81,14 +81,12 @@ void a_Prefs_init(void)
prefs.scroll_switches_tabs = TRUE; prefs.scroll_switches_tabs = TRUE;
prefs.scroll_switches_tabs_reverse = FALSE; prefs.scroll_switches_tabs_reverse = FALSE;
prefs.no_proxy = PREFS_NO_PROXY; prefs.no_proxy = PREFS_NO_PROXY;
prefs.link_actions = dList_new(16);
prefs.panel_size = P_medium; prefs.panel_size = P_medium;
prefs.parse_embedded_css=TRUE; prefs.parse_embedded_css=TRUE;
prefs.save_dir = PREFS_SAVE_DIR; prefs.save_dir = PREFS_SAVE_DIR;
prefs.scroll_step = 100; prefs.scroll_step = 100;
prefs.scroll_page_overlap = 50; prefs.scroll_page_overlap = 50;
prefs.search_urls = dList_new(16); prefs.search_urls.push_back(PREFS_SEARCH_URL);
dList_append(prefs.search_urls, dStrdup(PREFS_SEARCH_URL));
prefs.search_url_idx = 0; prefs.search_url_idx = 0;
prefs.scrollbar_on_left = FALSE; prefs.scrollbar_on_left = FALSE;
prefs.scrollbar_page_mode = FALSE; prefs.scrollbar_page_mode = FALSE;
@@ -140,9 +138,4 @@ void a_Prefs_init(void)
*/ */
void a_Prefs_freeall() 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);
} }
+5 -2
View File
@@ -15,6 +15,9 @@
#include "url.hh" #include "url.hh"
#include <string>
#include <vector>
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#else #else
@@ -119,7 +122,7 @@ struct DilloPrefs
bool scroll_switches_tabs; bool scroll_switches_tabs;
bool scroll_switches_tabs_reverse; bool scroll_switches_tabs_reverse;
bool search_url_idx; bool search_url_idx;
Dlist *search_urls; std::vector< std::string > search_urls;
std::optional< std::string > save_dir; std::optional< std::string > save_dir;
bool show_msg; bool show_msg;
bool show_extra_warnings; bool show_extra_warnings;
@@ -127,7 +130,7 @@ struct DilloPrefs
int penalty_hyphen, penalty_hyphen_2; int penalty_hyphen, penalty_hyphen_2;
int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2; int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2;
int stretchability_factor; int stretchability_factor;
Dlist *link_actions; std::vector< char * > link_actions;
}; };
/** Global Data */ /** Global Data */
+3 -3
View File
@@ -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 /* we found a ' ' in str, check whether the first part of str
* is a prefix of a search_url label * 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 *search =
(const char *)dList_nth_data(prefs.search_urls, p); prefs.search_urls.at(p).c_str();
if (search && dStrnAsciiCasecmp(str, search, len) == 0) { if (search && dStrnAsciiCasecmp(str, search, len) == 0) {
prefs.search_url_idx = p; prefs.search_url_idx = p;
url = UIcmd_make_search_str(str + len + 1); url = UIcmd_make_search_str(str + len + 1);
@@ -1164,7 +1164,7 @@ UIcmd_make_search_str(const char *str)
{ {
char *l, *u, *c; char *l, *u, *c;
std::string keys = a_Url_encode_hex_str(str).value_or( "" ); 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; std::string search_url;
/* parse search_url into label and url */ /* parse search_url into label and url */