Begin converting URL struct into modern C++ class

This commit is contained in:
2025-04-12 22:20:34 -04:00
parent 26b903f02f
commit 27ae7d91c1
18 changed files with 171 additions and 104 deletions

View File

@ -143,7 +143,7 @@ static DilloUrl *Url_object_new(const char *uri_str)
dReturn_val_if_fail (uri_str != NULL, NULL);
url = dNew0(DilloUrl, 1);
url = new DilloUrl{};
/* url->buffer is given a little extra room in case HSTS needs to transform
* a URL string ending in ":80" to ":443".
@ -214,7 +214,6 @@ DilloUrl::~DilloUrl()
if (this->hostname != this->authority)
dFree((char *)this->hostname);
dFree((char *)this->buffer);
dStr_free(this->data, 1);
}
/**
@ -424,7 +423,7 @@ DilloUrl* a_Url_new(const char *url_str, const char *base_url)
/* Fill url data */
url = Url_object_new(SolvedUrl->str);
url->data = dStr_new("");
url->data = "";
url->url_string = SolvedUrl;
url->illegal_chars = n_ic;
url->illegal_chars_spc = n_ic_spc;
@ -488,8 +487,7 @@ DilloUrl* a_Url_dup(const DilloUrl *ori)
url->ismap_url_len = ori->ismap_url_len;
url->illegal_chars = ori->illegal_chars;
url->illegal_chars_spc = ori->illegal_chars_spc;
url->data = dStr_sized_new(URL_DATA(ori)->len);
dStr_append_l(url->data, URL_DATA(ori)->str, URL_DATA(ori)->len);
url->data = ori->data;
return url;
}
@ -516,7 +514,7 @@ int a_Url_cmp(const DilloUrl *A, const DilloUrl *B)
B->path ? B->path + (*B->path == '/') : "")) == 0 &&
//(st = URL_STR_FIELD_CMP(A->path, B->path)) == 0 &&
(st = URL_STR_FIELD_CMP(A->query, B->query)) == 0 &&
(st = dStr_cmp(A->data, B->data)) == 0 &&
(st = strcmp(A->data.c_str(), B->data.c_str())) == 0 &&
(st = URL_STR_FIELD_I_CMP(A->scheme, B->scheme)) == 0))
return 0;
return st;
@ -534,13 +532,9 @@ void a_Url_set_flags(DilloUrl *u, int flags)
/**
* Set DilloUrl data (like POST info, etc.)
*/
void a_Url_set_data(DilloUrl *u, Dstr **data)
void a_Url_set_data(DilloUrl *u, std::string_view data)
{
if (u) {
dStr_free(u->data, 1);
u->data = *data;
*data = NULL;
}
u->data= data;
}
/**