Use RAII internally in the allocation function.

Next to return unique_ptr itself!
This commit is contained in:
2025-04-13 00:36:26 -04:00
parent 4005fa7e14
commit 7e03da3251

View File

@ -136,12 +136,11 @@ const char *a_Url_hostname(const DilloUrl *u)
*/
static DilloUrl *Url_object_new(const char *uri_str)
{
DilloUrl *url;
char *s, *p;
dReturn_val_if_fail (uri_str != NULL, NULL);
url = new DilloUrl{};
auto url = std::make_unique< DilloUrl >();
/* url->buffer is given a little extra room in case HSTS needs to transform
* a URL string ending in ":80" to ":443".
@ -171,7 +170,7 @@ static DilloUrl *Url_object_new(const char *uri_str)
s = p;
} else if (*s) {
url->authority = s;
return url;
return url.release();
}
}
@ -181,7 +180,7 @@ static DilloUrl *Url_object_new(const char *uri_str)
s = p;
} else if (*s) {
url->path = s;
return url;
return url.release();
}
p = strpbrk(s, "?#");
@ -198,7 +197,7 @@ static DilloUrl *Url_object_new(const char *uri_str)
url->fragment = s;
}
return url;
return url.release();
}
/**