From fb5c4c762a4b9f057e9e8bef908210ed326843489d0f32170bd2361ebc6c8946 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Mon, 4 Aug 2025 02:39:43 -0400 Subject: [PATCH] More local string management. --- src/domain.cc | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) diff --git a/src/domain.cc b/src/domain.cc index d3ffd19..da577da 100644 --- a/src/domain.cc +++ b/src/domain.cc @@ -10,6 +10,7 @@ #include #include +#include #include "../dlib/dlib.h" #include "msg.hh" @@ -17,8 +18,8 @@ #include "domain.hh" struct Rule { - char *origin; - char *destination; + std::string origin; + std::string destination; }; std::vector< Rule > exceptions; @@ -64,10 +65,8 @@ void a_Domain_parse(FILE *fp) MSG("Domain: Default action \"%s\" not recognised.\n", tok2); } } else { - exceptions.emplace_back(); - exceptions.back().origin = dStrdup(tok1); - exceptions.back().destination = dStrdup(tok2); - _MSG("Domain: Exception from %s to %s.\n", tok1, tok2); + exceptions.emplace_back( tok1, tok2 ); + _MSG("Domain: Exception from %s to %s.\n", tok1.c_str(), tok2.c_str()); } } } @@ -77,12 +76,6 @@ void a_Domain_parse(FILE *fp) void a_Domain_freeall(void) { - int i = 0; - - for (i = 0; i < exceptions.size(); i++) { - dFree(exceptions[i].origin); - dFree(exceptions[i].destination); - } exceptions.clear(); } @@ -138,11 +131,11 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest) ret = default_deny ? FALSE : TRUE; for (i = 0; i < exceptions.size(); i++) { - if (Domain_match(source_host, exceptions[i].origin) && - Domain_match(dest_host, exceptions[i].destination)) { + if (Domain_match(source_host, exceptions[i].origin.c_str()) && + Domain_match(dest_host, exceptions[i].destination.c_str())) { ret = default_deny; - _MSG("Domain: Matched rule from %s to %s.\n", exceptions[i].origin, - exceptions[i].destination); + _MSG("Domain: Matched rule from %s to %s.\n", exceptions[i].origin.c_str(), + exceptions[i].destination.c_str()); break; } }