From 7fa911498456f1e550a54aa1dac3bcbdb688082097ab565f09511421baa61f36 Mon Sep 17 00:00:00 2001 From: ADAM David Alan Martin Date: Fri, 9 Jan 2026 21:53:25 -0500 Subject: [PATCH] Http.cc now uses one fewer dList. --- src/IO/http.cc | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/IO/http.cc b/src/IO/http.cc index 114552f..3d322a4 100644 --- a/src/IO/http.cc +++ b/src/IO/http.cc @@ -81,7 +81,7 @@ struct SocketData_t { /* Data structures and functions to queue sockets that need to be * delayed due to the per host connection limit. */ -typedef struct { +struct Server_t { char *host; uint_t port; bool https; @@ -89,7 +89,7 @@ typedef struct { int active_conns; int running_the_queue; Dlist *queue; -} Server_t; +}; struct FdMapEntry_t { int fd; @@ -112,7 +112,7 @@ static Klist_t *ValidSocks = NULL; /* Active sockets list. It holds pointers to static DilloUrl *HTTP_Proxy = NULL; static char *HTTP_Proxy_Auth_base64 = NULL; static char *HTTP_Language_hdr = NULL; -static Dlist *servers; +static std::vector< Server_t * > servers; /* TODO: If fd_map will stick around in its present form (FDs and SocketData_t) * then consider whether having both this and ValidSocks is necessary. @@ -142,8 +142,6 @@ int a_Http_init(void) HTTP_Proxy_Auth_base64 = a_Misc_encode_base64(prefs.http_proxyuser); */ - servers = dList_new(5); - return 0; } @@ -1073,8 +1071,8 @@ static Server_t *Http_server_get(const char *host, uint_t port, bool https) int i; Server_t *srv; - for (i = 0; i < dList_length(servers); i++) { - srv = (Server_t*) dList_nth_data(servers, i); + for (i = 0; i < servers.size(); i++) { + srv = servers.at( i ); if (port == srv->port && https == srv->https && !dStrAsciiCasecmp(host, srv->host)) @@ -1087,7 +1085,7 @@ static Server_t *Http_server_get(const char *host, uint_t port, bool https) srv->host = dStrdup(host); srv->port = port; srv->https = https; - dList_append(servers, srv); + servers.push_back( srv ); return srv; } @@ -1101,7 +1099,7 @@ static void Http_server_remove(Server_t *srv) delete sd; } dList_free(srv->queue); - dList_remove_fast(servers, srv); + servers.erase( std::find( begin( servers ), end( servers ), srv ) ); dFree(srv->host); dFree(srv); } @@ -1111,15 +1109,15 @@ static void Http_servers_remove_all(void) Server_t *srv; SocketData_t *sd; - while (dList_length(servers) > 0) { - srv = (Server_t*) dList_nth_data(servers, 0); + while (not servers.empty()) { + srv = servers.at( 0 ); while ((sd = reinterpret_cast< SocketData_t * >( dList_nth_data(srv->queue, 0) ))) { dList_remove(srv->queue, sd); dFree(sd); } Http_server_remove(srv); } - dList_free(servers); + servers.clear(); } static void Http_fd_map_remove_all(void)