urlapi: leaner with fewer allocs

Slightly faster with more robust code. Uses fewer and smaller mallocs.

- remove two fields from the URL handle struct
- reduce copies and allocs
- use dynbuf buffers more instead of custom malloc + copies
- uses dynbuf to build the host name in reduces serial alloc+free within
  the same function.
- move dedotdotify into urlapi.c and make it static, not strdup the input
  and optimize it by checking for . and / before using strncmp
- remove a few strlen() calls
- add Curl_dyn_setlen() that can "trim" an existing dynbuf

Closes #9408
This commit is contained in:
Daniel Stenberg 2022-09-01 10:16:24 +02:00
parent 2ae81e680b
commit f703cf971c
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
11 changed files with 565 additions and 596 deletions

View file

@ -25,10 +25,11 @@
***************************************************************************/
#include "curl_setup.h"
bool Curl_is_absolute_url(const char *url, char *scheme, size_t buflen);
size_t Curl_is_absolute_url(const char *url, char *buf, size_t buflen);
#ifdef DEBUGBUILD
CURLUcode Curl_parse_port(struct Curl_URL *u, char *hostname, bool);
CURLUcode Curl_parse_port(struct Curl_URL *u, struct dynbuf *host,
bool has_scheme);
#endif
#endif /* HEADER_CURL_URLAPI_INT_H */