summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-09-23 09:21:36 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-09-23 15:13:46 +0200
commitf74afa40f8b6b87ccf74a4ca70b5514a9a87e6f1 (patch)
tree1a8861b58722ec8079370048bd6aef686cd768dc
parent7e8561e030fcfaba5cd620d7e9c9ab8356163132 (diff)
downloadcurl-f74afa40f8b6b87ccf74a4ca70b5514a9a87e6f1.tar.gz
dynbuf: add Curl_dyn_vaddf
Closes #6004
-rw-r--r--docs/DYNBUF.md6
-rw-r--r--lib/dynbuf.c28
-rw-r--r--lib/dynbuf.h4
3 files changed, 30 insertions, 8 deletions
diff --git a/docs/DYNBUF.md b/docs/DYNBUF.md
index 382c1365d..aa528ec3a 100644
--- a/docs/DYNBUF.md
+++ b/docs/DYNBUF.md
@@ -42,6 +42,12 @@ Append a C string to the end of the buffer.
Append a `printf()`-style string to the end of the buffer.
+## vaddf
+
+ CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap);
+
+Append a `vprintf()`-style string to the end of the buffer.
+
## reset
void Curl_dyn_reset(struct dynbuf *s);
diff --git a/lib/dynbuf.c b/lib/dynbuf.c
index 2dace3428..b2465b888 100644
--- a/lib/dynbuf.c
+++ b/lib/dynbuf.c
@@ -177,24 +177,22 @@ CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
}
/*
- * Append a string printf()-style
+ * Append a string vprintf()-style
*/
-CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
+CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
{
- va_list ap;
#ifdef BUILDING_LIBCURL
int rc;
- va_start(ap, fmt);
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
rc = Curl_dyn_vprintf(s, fmt, ap);
- va_end(ap);
if(!rc)
return CURLE_OK;
#else
char *str;
- va_start(ap, fmt);
str = vaprintf(fmt, ap); /* this allocs a new string to append */
- va_end(ap);
if(str) {
CURLcode result = dyn_nappend(s, (unsigned char *)str, strlen(str));
@@ -207,7 +205,21 @@ CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
return CURLE_OUT_OF_MEMORY;
}
-
+/*
+ * Append a string printf()-style
+ */
+CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
+{
+ CURLcode result;
+ va_list ap;
+ DEBUGASSERT(s);
+ DEBUGASSERT(s->init == DYNINIT);
+ DEBUGASSERT(!s->leng || s->bufr);
+ va_start(ap, fmt);
+ result = Curl_dyn_vaddf(s, fmt, ap);
+ va_end(ap);
+ return result;
+}
/*
* Returns a pointer to the buffer.
diff --git a/lib/dynbuf.h b/lib/dynbuf.h
index 94b5dbf68..90a4f6622 100644
--- a/lib/dynbuf.h
+++ b/lib/dynbuf.h
@@ -29,6 +29,7 @@
#define Curl_dyn_add(a,b) curlx_dyn_add(a,b)
#define Curl_dyn_addn(a,b,c) curlx_dyn_addn(a,b,c)
#define Curl_dyn_addf curlx_dyn_addf
+#define Curl_dyn_vaddf curlx_dyn_vaddf
#define Curl_dyn_free(a) curlx_dyn_free(a)
#define Curl_dyn_ptr(a) curlx_dyn_ptr(a)
#define Curl_dyn_uptr(a) curlx_dyn_uptr(a)
@@ -56,6 +57,8 @@ CURLcode Curl_dyn_add(struct dynbuf *s, const char *str)
WARN_UNUSED_RESULT;
CURLcode Curl_dyn_addf(struct dynbuf *s, const char *fmt, ...)
WARN_UNUSED_RESULT;
+CURLcode Curl_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap)
+ WARN_UNUSED_RESULT;
void Curl_dyn_reset(struct dynbuf *s);
CURLcode Curl_dyn_tail(struct dynbuf *s, size_t trail);
char *Curl_dyn_ptr(const struct dynbuf *s);
@@ -80,4 +83,5 @@ int Curl_dyn_vprintf(struct dynbuf *dyn, const char *format, va_list ap_save);
#define DYN_PROXY_CONNECT_HEADERS 16384
#define DYN_QLOG_NAME 1024
#define DYN_H1_TRAILER 4096
+#define DYN_PINGPPONG_CMD (64*1024)
#endif