mirror of
https://github.com/curl/curl.git
synced 2026-07-27 21:23:06 +03:00
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:
parent
2ae81e680b
commit
f703cf971c
11 changed files with 565 additions and 596 deletions
|
|
@ -76,7 +76,8 @@ CURLcode Curl_dyn_tail(struct dynbuf *s, size_t length);
|
|||
|
||||
Keep `length` bytes of the buffer tail (the last `length` bytes of the
|
||||
buffer). The rest of the buffer is dropped. The specified `length` must not be
|
||||
larger than the buffer length.
|
||||
larger than the buffer length. To instead keep the leading part, see
|
||||
`Curl_dyn_setlen()`.
|
||||
|
||||
## ptr
|
||||
|
||||
|
|
@ -106,3 +107,13 @@ size_t Curl_dyn_len(const struct dynbuf *s);
|
|||
|
||||
Returns the length of the buffer in bytes. Does not include the terminating
|
||||
zero byte.
|
||||
|
||||
## setlen
|
||||
|
||||
```c
|
||||
CURLcode Curl_dyn_setlen(struct dynbuf *s, size_t len);
|
||||
```
|
||||
|
||||
Sets the new shorter length of the buffer in number of bytes. Keeps the
|
||||
leftmost set number of bytes, discards the rest. To instead keep the tail part
|
||||
of the buffer, see `Curl_dyn_tail()`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue