diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-09-22 17:28:34 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-09-23 08:54:42 +0200 |
commit | 7e8561e030fcfaba5cd620d7e9c9ab8356163132 (patch) | |
tree | bede470aac7ebaea20edbd604624050cac54fb7e /lib/dynbuf.h | |
parent | 23558577023538a17c70933acc5de04bf350d9c2 (diff) | |
download | curl-7e8561e030fcfaba5cd620d7e9c9ab8356163132.tar.gz |
dynbuf: make *addf() not require extra mallocs
... by introducing a printf() function that appends directly into a
dynbuf: Curl_dyn_vprintf(). This avoids the mandatory extra malloc so if
the buffer is already big enough it can just printf directly into it.
Since this less-malloc version requires tthe use of a library internal
printf function, we only provide this version when building libcurl and
not for the dynbuf code that is used when building the curl tool.
Closes #5998
Diffstat (limited to 'lib/dynbuf.h')
-rw-r--r-- | lib/dynbuf.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/dynbuf.h b/lib/dynbuf.h index 1360dd432..94b5dbf68 100644 --- a/lib/dynbuf.h +++ b/lib/dynbuf.h @@ -62,6 +62,10 @@ char *Curl_dyn_ptr(const struct dynbuf *s); unsigned char *Curl_dyn_uptr(const struct dynbuf *s); size_t Curl_dyn_len(const struct dynbuf *s); +/* returns 0 on success, -1 on error */ +/* The implementation of this function exists in mprintf.c */ +int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save); + /* Dynamic buffer max sizes */ #define DYN_DOH_RESPONSE 3000 #define DYN_DOH_CNAME 256 |