From 122d3f894e4f8fc939fcbb06bf42cfdc4c896d171e6c939b9f7663fa49602720 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Wed, 7 Jan 2026 04:37:28 -0500 Subject: [PATCH] Preferences own some strings now. --- src/cache.cc | 2 +- src/flenser.cc | 12 ++++++------ src/prefs.cc | 15 +++++---------- src/prefs.hh | 15 ++++++++------- src/styleengine.cc | 15 ++++++++------- 5 files changed, 28 insertions(+), 31 deletions(-) diff --git a/src/cache.cc b/src/cache.cc index 55caabb..602cf34 100644 --- a/src/cache.cc +++ b/src/cache.cc @@ -1197,7 +1197,7 @@ static CacheEntry_t *Cache_process_queue(CacheEntry_t *entry) entry->TypeHdr); TypeMismatch = true; } - entry->TypeDet = dStrdup(Type); + entry->TypeDet = Type; entry->Flags |= CA_GotContentType; } else return entry; /* i.e., wait for more data */ diff --git a/src/flenser.cc b/src/flenser.cc index 34ac4e2..5353240 100644 --- a/src/flenser.cc +++ b/src/flenser.cc @@ -213,11 +213,11 @@ static void checkFont(const char *name, const char *type) static void checkPreferredFonts() { - checkFont(prefs.font_sans_serif, "sans-serif"); - checkFont(prefs.font_serif, "serif"); - checkFont(prefs.font_monospace, "monospace"); - checkFont(prefs.font_cursive, "cursive"); - checkFont(prefs.font_fantasy, "fantasy"); + checkFont(prefs.font_sans_serif.c_str(), "sans-serif"); + checkFont(prefs.font_serif.c_str(), "serif"); + checkFont(prefs.font_monospace.c_str(), "monospace"); + checkFont(prefs.font_cursive.c_str(), "cursive"); + checkFont(prefs.font_fantasy.c_str(), "fantasy"); } /** @@ -428,7 +428,7 @@ int main(int argc, char **argv) checkPreferredFonts(); /* use preferred font for UI */ - Fl_Font defaultFont = dw::fltk::FltkFont::get (prefs.font_sans_serif, 0); + Fl_Font defaultFont = dw::fltk::FltkFont::get (prefs.font_sans_serif.c_str(), 0); Fl::set_font(FL_HELVETICA, defaultFont); // this seems to be the // only way to set the // default font in fltk1.3 diff --git a/src/prefs.cc b/src/prefs.cc index ad50b1c..7fa62cb 100644 --- a/src/prefs.cc +++ b/src/prefs.cc @@ -45,15 +45,15 @@ void a_Prefs_init(void) prefs.contrast_visited_color = TRUE; prefs.enterpress_forces_submit = FALSE; prefs.focus_new_tab = FALSE; - prefs.font_cursive = dStrdup(PREFS_FONT_CURSIVE); + prefs.font_cursive = (PREFS_FONT_CURSIVE); prefs.font_factor = 1.0; prefs.zoom_factor = 1.0; prefs.font_max_size = 100; prefs.font_min_size = 6; - prefs.font_fantasy = dStrdup(PREFS_FONT_FANTASY); - prefs.font_monospace = dStrdup(PREFS_FONT_MONOSPACE); - prefs.font_sans_serif = dStrdup(PREFS_FONT_SANS_SERIF); - prefs.font_serif = dStrdup(PREFS_FONT_SERIF); + prefs.font_fantasy = (PREFS_FONT_FANTASY); + prefs.font_monospace = (PREFS_FONT_MONOSPACE); + prefs.font_sans_serif = (PREFS_FONT_SANS_SERIF); + prefs.font_serif = (PREFS_FONT_SERIF); prefs.fullwindow_start = FALSE; /* these four constitute the geometry */ @@ -146,11 +146,6 @@ void a_Prefs_freeall(void) { int i; - dFree(prefs.font_cursive); - dFree(prefs.font_fantasy); - dFree(prefs.font_monospace); - dFree(prefs.font_sans_serif); - dFree(prefs.font_serif); delete prefs.home; dFree(prefs.http_language); delete prefs.http_proxy; diff --git a/src/prefs.hh b/src/prefs.hh index 96096f0..ccd9a55 100644 --- a/src/prefs.hh +++ b/src/prefs.hh @@ -36,7 +36,8 @@ extern "C" { /** Panel sizes. */ enum { P_tiny = 0, P_small, P_medium }; -typedef struct { +struct DilloPrefs +{ int width; int height; int xpos; @@ -107,11 +108,11 @@ typedef struct { bool http_strict_transport_security; bool http_force_https; int32_t buffered_drawing; - char *font_serif; - char *font_sans_serif; - char *font_cursive; - char *font_fantasy; - char *font_monospace; + std::string font_serif; + std::string font_sans_serif; + std::string font_cursive; + std::string font_fantasy; + std::string font_monospace; bool enterpress_forces_submit; bool middle_click_opens_new_tab; bool right_click_closes_tab; @@ -127,7 +128,7 @@ typedef struct { int penalty_em_dash_left, penalty_em_dash_right, penalty_em_dash_right_2; int stretchability_factor; Dlist *link_actions; -} DilloPrefs; +}; /** Global Data */ extern DilloPrefs prefs; diff --git a/src/styleengine.cc b/src/styleengine.cc index 35be711..a3d2df2 100644 --- a/src/styleengine.cc +++ b/src/styleengine.cc @@ -82,7 +82,7 @@ StyleEngine::StyleEngine (dw::core::Layout *layout, Node *n = &stack.back (); /* Create a dummy font, attribute, and tag for the bottom of the stack. */ - font_attrs.name = prefs.font_sans_serif; + font_attrs.name = prefs.font_sans_serif.c_str(); font_attrs.size = roundInt(14 * prefs.font_factor * zoom); if (font_attrs.size < prefs.font_min_size) font_attrs.size = prefs.font_min_size; @@ -356,7 +356,8 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, BrowserWindow *bw) { FontAttrs fontAttrs = *attrs->font; Font *parentFont = stack.at (i - 1).style->font; - char *c, *fontName; + char *c; + const char *fontName; int lineHeight; std::unique_ptr< DilloUrl > imgUrl; @@ -376,15 +377,15 @@ void StyleEngine::apply (int i, StyleAttrs *attrs, CssPropertyList *props, dStrstrip(p->value.strVal); if (dStrAsciiCasecmp (p->value.strVal, "serif") == 0) - fontName = prefs.font_serif; + fontName = prefs.font_serif.c_str(); else if (dStrAsciiCasecmp (p->value.strVal, "sans-serif") == 0) - fontName = prefs.font_sans_serif; + fontName = prefs.font_sans_serif.c_str(); else if (dStrAsciiCasecmp (p->value.strVal, "cursive") == 0) - fontName = prefs.font_cursive; + fontName = prefs.font_cursive.c_str(); else if (dStrAsciiCasecmp (p->value.strVal, "fantasy") == 0) - fontName = prefs.font_fantasy; + fontName = prefs.font_fantasy.c_str(); else if (dStrAsciiCasecmp (p->value.strVal, "monospace") == 0) - fontName = prefs.font_monospace; + fontName = prefs.font_monospace.c_str(); else if (Font::exists(layout, p->value.strVal)) fontName = p->value.strVal;