urlapi: do not keep an internal port string

Do not allocated an internal port string, just keep and number and a bit
if it is present. Format the port string in a local buffer when someone
asks for it and copy that.

This avoid the format/alloc penalty when parsing URLs and no one ever
asking for the port string.

(And there will be a method to get the uint16_t value directly in
 another PR)

Closes #22167
This commit is contained in:
Stefan Eissing 2026-06-25 11:18:27 +02:00 committed by Daniel Stenberg
parent d2fe26cfe2
commit 26c6a4d898
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
2 changed files with 49 additions and 45 deletions

View file

@ -34,11 +34,11 @@ struct Curl_URL {
char *options; /* IMAP only? */
char *host;
char *zoneid; /* for numerical IPv6 addresses */
char *port;
char *path;
char *query;
char *fragment;
unsigned short portnum; /* the numerical version (if 'port' is set) */
uint16_t portnum; /* the numerical port if present */
BIT(port_present); /* to support missing port */
BIT(query_present); /* to support blank */
BIT(fragment_present); /* to support blank */
BIT(guessed_scheme); /* when a URL without scheme is parsed */