lib: turn state.url into a struct bufref

Closes #19827
This commit is contained in:
Patrick Monnerat 2025-12-03 23:15:18 +01:00 committed by Daniel Stenberg
parent f39b8a1174
commit 36542b7349
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
16 changed files with 67 additions and 82 deletions

View file

@ -54,6 +54,7 @@
#include "tftp.h"
#include "strdup.h"
#include "escape.h"
#include "bufref.h"
static CURLcode setopt_set_timeout_sec(timediff_t *ptimeout_ms, long secs)
{
@ -1971,12 +1972,8 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
/*
* The URL to fetch.
*/
if(data->state.url_alloc) {
Curl_safefree(data->state.url);
data->state.url_alloc = FALSE;
}
result = Curl_setstropt(&s->str[STRING_SET_URL], ptr);
data->state.url = s->str[STRING_SET_URL];
Curl_bufref_set(&data->state.url, s->str[STRING_SET_URL], 0, NULL);
break;
case CURLOPT_USERPWD:
@ -2063,12 +2060,7 @@ static CURLcode setopt_cptr(struct Curl_easy *data, CURLoption option,
/*
* pass CURLU to set URL
*/
if(data->state.url_alloc) {
Curl_safefree(data->state.url);
data->state.url_alloc = FALSE;
}
else
data->state.url = NULL;
Curl_bufref_free(&data->state.url);
Curl_safefree(s->str[STRING_SET_URL]);
s->uh = (CURLU *)ptr;
break;