summaryrefslogtreecommitdiff
path: root/lib/url.c
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2021-01-19 15:57:24 +0100
committerDaniel Stenberg <daniel@haxx.se>2021-01-20 09:02:24 +0100
commit6246a1d8c6776a60f266f1906f0ef9048e9e1069 (patch)
tree2773ae0bf184bc357b07c2c8a381f1680f41871b /lib/url.c
parentd0688dcbdf412273e276dd29135b952f2065cb5b (diff)
downloadcurl-6246a1d8c6776a60f266f1906f0ef9048e9e1069.tar.gz
doh: allocate state struct on demand
... instead of having it static within the Curl_easy struct. This takes away 1176 bytes (18%) from the Curl_easy struct that aren't used very often and instead makes the code allocate it when needed. Closes #6492
Diffstat (limited to 'lib/url.c')
-rw-r--r--lib/url.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/lib/url.c b/lib/url.c
index 4a145b028..fe6c9a1f2 100644
--- a/lib/url.c
+++ b/lib/url.c
@@ -451,9 +451,12 @@ CURLcode Curl_close(struct Curl_easy **datap)
Curl_safefree(data->state.aptr.rtsp_transport);
#ifndef CURL_DISABLE_DOH
- Curl_dyn_free(&data->req.doh.probe[0].serverdoh);
- Curl_dyn_free(&data->req.doh.probe[1].serverdoh);
- curl_slist_free_all(data->req.doh.headers);
+ if(data->req.doh) {
+ Curl_dyn_free(&data->req.doh->probe[0].serverdoh);
+ Curl_dyn_free(&data->req.doh->probe[1].serverdoh);
+ curl_slist_free_all(data->req.doh->headers);
+ Curl_safefree(data->req.doh);
+ }
#endif
/* destruct wildcard structures if it is needed */
@@ -2138,8 +2141,10 @@ void Curl_free_request_state(struct Curl_easy *data)
Curl_safefree(data->req.newurl);
#ifndef CURL_DISABLE_DOH
- Curl_close(&data->req.doh.probe[0].easy);
- Curl_close(&data->req.doh.probe[1].easy);
+ if(data->req.doh) {
+ Curl_close(&data->req.doh->probe[0].easy);
+ Curl_close(&data->req.doh->probe[1].easy);
+ }
#endif
}