From f384d407189f183ae8a128bf8039b9d0c9a5115a Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 10 Mar 2023 08:39:47 +0100 Subject: [PATCH] url: remove dummy protocol handler Just two added checks were needed saves a whole handler struct. Closes #10727 --- lib/multi.c | 2 +- lib/url.c | 33 +-------------------------------- 2 files changed, 2 insertions(+), 33 deletions(-) diff --git a/lib/multi.c b/lib/multi.c index 2f0d020afd..3bf72ce655 100644 --- a/lib/multi.c +++ b/lib/multi.c @@ -976,7 +976,7 @@ void Curl_attach_connection(struct Curl_easy *data, data->conn = conn; Curl_llist_insert_next(&conn->easyq, conn->easyq.tail, data, &data->conn_queue); - if(conn->handler->attach) + if(conn->handler && conn->handler->attach) conn->handler->attach(data, conn); Curl_conn_ev_data_attach(conn, data); } diff --git a/lib/url.c b/lib/url.c index 1b419a08b3..df6ef12134 100644 --- a/lib/url.c +++ b/lib/url.c @@ -288,33 +288,6 @@ static const struct Curl_handler * const protocols[] = { (struct Curl_handler *) NULL }; -/* - * Dummy handler for undefined protocol schemes. - */ - -static const struct Curl_handler Curl_handler_dummy = { - "", /* scheme */ - ZERO_NULL, /* setup_connection */ - ZERO_NULL, /* do_it */ - ZERO_NULL, /* done */ - ZERO_NULL, /* do_more */ - ZERO_NULL, /* connect_it */ - ZERO_NULL, /* connecting */ - ZERO_NULL, /* doing */ - ZERO_NULL, /* proto_getsock */ - ZERO_NULL, /* doing_getsock */ - ZERO_NULL, /* domore_getsock */ - ZERO_NULL, /* perform_getsock */ - ZERO_NULL, /* disconnect */ - ZERO_NULL, /* readwrite */ - ZERO_NULL, /* connection_check */ - ZERO_NULL, /* attach connection */ - 0, /* defport */ - 0, /* protocol */ - 0, /* family */ - PROTOPT_NONE /* flags */ -}; - void Curl_freeset(struct Curl_easy *data) { /* Free all dynamic strings stored in the data->set substructure. */ @@ -825,7 +798,7 @@ void Curl_disconnect(struct Curl_easy *data, disconnect and shutdown */ Curl_attach_connection(data, conn); - if(conn->handler->disconnect) + if(conn->handler && conn->handler->disconnect) /* This is set if protocol-specific cleanups should be made */ conn->handler->disconnect(data, conn, dead_connection); @@ -1509,10 +1482,6 @@ static struct connectdata *allocate_conn(struct Curl_easy *data) if(!conn) return NULL; - conn->handler = &Curl_handler_dummy; /* Be sure we have a handler defined - already from start to avoid NULL - situations and checks */ - /* and we setup a few fields in case we end up actually using this struct */ conn->sock[FIRSTSOCKET] = CURL_SOCKET_BAD; /* no file descriptor */ -- 2.47.3