From: Daniel Gustafsson Date: Mon, 13 May 2024 07:07:30 +0000 (+0200) Subject: hsts: Remove single-use single-line function X-Git-Tag: curl-8_8_0~78 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4d96873a4d50b3c16c280307dee91be01f1fdc0b;p=thirdparty%2Fcurl.git hsts: Remove single-use single-line function The hsts_entry() function contains of a single line and is only used in a single place in the code, so move the allocation into hsts_create instead to improve code readability. C code usually don't use the factory abstraction for object creation, and this small example wasn't following our usual code style. Closes: #13604 Reviewed-by: Daniel Stenberg --- diff --git a/lib/hsts.c b/lib/hsts.c index d006e68869..72b80a46ca 100644 --- a/lib/hsts.c +++ b/lib/hsts.c @@ -107,11 +107,6 @@ void Curl_hsts_cleanup(struct hsts **hp) } } -static struct stsentry *hsts_entry(void) -{ - return calloc(1, sizeof(struct stsentry)); -} - static CURLcode hsts_create(struct hsts *h, const char *hostname, bool subdomains, @@ -127,7 +122,7 @@ static CURLcode hsts_create(struct hsts *h, --hlen; if(hlen) { char *duphost; - struct stsentry *sts = hsts_entry(); + struct stsentry *sts = calloc(1, sizeof(struct stsentry)); if(!sts) return CURLE_OUT_OF_MEMORY;