aboutsummaryrefslogtreecommitdiff
path: root/lib/urldata.h
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2020-05-02 17:04:08 +0200
committerDaniel Stenberg <daniel@haxx.se>2020-05-04 10:40:39 +0200
commited35d6590e72c23c568af1e3b8ac6e4e2d883888 (patch)
tree57555732f4f452bf84c3c7296581485be064a853 /lib/urldata.h
parent00c2e8da9a9555ce6171e3f7ddc5e43fc6f9bb4b (diff)
dynbuf: introduce internal generic dynamic buffer functions
A common set of functions instead of many separate implementations for creating buffers that can grow when appending data to them. Existing functionality has been ported over. In my early basic testing, the total number of allocations seem at roughly the same amount as before, possibly a few less. See docs/DYNBUF.md for a description of the API. Closes #5300
Diffstat (limited to 'lib/urldata.h')
-rw-r--r--lib/urldata.h25
1 files changed, 6 insertions, 19 deletions
diff --git a/lib/urldata.h b/lib/urldata.h
index 50d8b84a6..7eaa3513e 100644
--- a/lib/urldata.h
+++ b/lib/urldata.h
@@ -104,6 +104,7 @@
#include "hostip.h"
#include "hash.h"
#include "splay.h"
+#include "dynbuf.h"
/* return the count of bytes sent, or -1 on error */
typedef ssize_t (Curl_send)(struct connectdata *conn, /* connection data */
@@ -556,18 +557,13 @@ enum doh_slots {
DOH_PROBE_SLOTS
};
-struct dohresponse {
- unsigned char *memory;
- size_t size;
-};
-
/* one of these for each DoH request */
struct dnsprobe {
CURL *easy;
int dnstype;
unsigned char dohbuffer[512];
size_t dohlen;
- struct dohresponse serverdoh;
+ struct dynbuf serverdoh;
};
struct dohdata {
@@ -611,12 +607,7 @@ struct SingleRequest {
written as body */
int headerline; /* counts header lines to better track the
first one */
- char *hbufp; /* points at *end* of header line */
- size_t hbuflen;
char *str; /* within buf */
- char *str_start; /* within buf */
- char *end_ptr; /* within buf */
- char *p; /* within headerbuff */
curl_off_t offset; /* possible resume offset read from the
Content-Range: header */
int httpcode; /* error code from the 'HTTP/1.? XXX' or
@@ -1278,9 +1269,7 @@ struct Curl_http2_dep {
* BODY).
*/
struct tempbuf {
- char *buf; /* allocated buffer to keep data in when a write callback
- returns to make the connection paused */
- size_t len; /* size of the 'tempwrite' allocated buffer */
+ struct dynbuf b;
int type; /* type of the 'tempwrite' buffer as a bitmask that is used with
Curl_client_write() */
};
@@ -1340,9 +1329,7 @@ struct UrlState {
struct curltime keeps_speed; /* for the progress meter really */
struct connectdata *lastconnect; /* The last connection, NULL if undefined */
-
- char *headerbuff; /* allocated buffer to store headers in */
- size_t headersize; /* size of the allocation */
+ struct dynbuf headerb; /* buffer to store headers in */
char *buffer; /* download buffer */
char *ulbuf; /* allocated upload buffer or NULL */
@@ -1422,8 +1409,8 @@ struct UrlState {
struct urlpieces up;
#ifndef CURL_DISABLE_HTTP
size_t trailers_bytes_sent;
- Curl_send_buffer *trailers_buf; /* a buffer containing the compiled trailing
- headers */
+ struct dynbuf trailers_buf; /* a buffer containing the compiled trailing
+ headers */
#endif
trailers_state trailers_state; /* whether we are sending trailers
and what stage are we at */