Artifactspublic-v0

curl

master
ply4 git calls31 ms288 KiB3 cachedprotocol v2
145 lines3.7 KiBRaw

dynbuf

This is the internal module for creating and handling "dynamic buffers". This means buffers that can be appended to, dynamically and grow to adapt.

There is always a null-terminator put at the end of the dynamic buffer.

The struct dynbuf is used to hold data for each instance of a dynamic buffer. The members of that struct MUST NOT be accessed or modified without using the dedicated dynbuf API.

curlx_dyn_init

c
void curlx_dyn_init(struct dynbuf *s, size_t toobig);

This initializes a struct to use for dynbuf and it cannot fail. The toobig value must be set to the maximum size we allow this buffer instance to grow to. The functions below return CURLE_OUT_OF_MEMORY when hitting this limit.

curlx_dyn_free

c
void curlx_dyn_free(struct dynbuf *s);

Free the associated memory and clean up. After a free, the dynbuf struct can be reused to start appending new data to.

curlx_dyn_addn

c
CURLcode curlx_dyn_addn(struct dynbuf *s, const void *mem, size_t len);

Append arbitrary data of a given length to the end of the buffer.

If this function fails it calls curlx_dyn_free on dynbuf.

curlx_dyn_add

c
CURLcode curlx_dyn_add(struct dynbuf *s, const char *str);

Append a C string to the end of the buffer.

If this function fails it calls curlx_dyn_free on dynbuf.

curlx_dyn_addf

c
CURLcode curlx_dyn_addf(struct dynbuf *s, const char *fmt, ...);

Append a printf()-style string to the end of the buffer.

If this function fails it calls curlx_dyn_free on dynbuf.

curlx_dyn_vaddf

c
CURLcode curlx_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap);

Append a vprintf()-style string to the end of the buffer.

If this function fails it calls curlx_dyn_free on dynbuf.

curlx_dyn_reset

c
void curlx_dyn_reset(struct dynbuf *s);

Reset the buffer length, but leave the allocation.

curlx_dyn_tail

c
CURLcode curlx_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. To instead keep the leading part, see curlx_dyn_setlen().

curlx_dyn_ptr

c
char *curlx_dyn_ptr(const struct dynbuf *s);

Returns a char * to the buffer if it has a length, otherwise may return NULL. Since the buffer may be reallocated, this pointer should not be trusted or used anymore after the next buffer manipulation call.

curlx_dyn_uptr

c
unsigned char *curlx_dyn_uptr(const struct dynbuf *s);

Returns an unsigned char * to the buffer if it has a length, otherwise may return NULL. Since the buffer may be reallocated, this pointer should not be trusted or used anymore after the next buffer manipulation call.

curlx_dyn_len

c
size_t curlx_dyn_len(const struct dynbuf *s);

Returns the length of the buffer in bytes. Does not include the null-terminator byte.

curlx_dyn_setlen

c
CURLcode curlx_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 curlx_dyn_tail().

curlx_dyn_take

c
char *curlx_dyn_take(struct dynbuf *s, size_t *plen);

Transfers ownership of the internal buffer to the caller. The dynbuf resets to its initial state. The returned pointer may be NULL if the dynbuf never allocated memory. The returned length is the amount of data written to the buffer. The actual allocated memory might be larger.

1<!--
2Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
4SPDX-License-Identifier: curl
5-->
7# dynbuf
9This is the internal module for creating and handling "dynamic buffers". This
10means buffers that can be appended to, dynamically and grow to adapt.
12There is always a null-terminator put at the end of the dynamic buffer.
14The `struct dynbuf` is used to hold data for each instance of a dynamic
15buffer. The members of that struct **MUST NOT** be accessed or modified
16without using the dedicated dynbuf API.
18## `curlx_dyn_init`
20```c
21void curlx_dyn_init(struct dynbuf *s, size_t toobig);
22```
24This initializes a struct to use for dynbuf and it cannot fail. The `toobig`
25value **must** be set to the maximum size we allow this buffer instance to
26grow to. The functions below return `CURLE_OUT_OF_MEMORY` when hitting this
27limit.
29## `curlx_dyn_free`
31```c
32void curlx_dyn_free(struct dynbuf *s);
33```
35Free the associated memory and clean up. After a free, the `dynbuf` struct can
36be reused to start appending new data to.
38## `curlx_dyn_addn`
40```c
41CURLcode curlx_dyn_addn(struct dynbuf *s, const void *mem, size_t len);
42```
44Append arbitrary data of a given length to the end of the buffer.
46If this function fails it calls `curlx_dyn_free` on `dynbuf`.
48## `curlx_dyn_add`
50```c
51CURLcode curlx_dyn_add(struct dynbuf *s, const char *str);
52```
54Append a C string to the end of the buffer.
56If this function fails it calls `curlx_dyn_free` on `dynbuf`.
58## `curlx_dyn_addf`
60```c
61CURLcode curlx_dyn_addf(struct dynbuf *s, const char *fmt, ...);
62```
64Append a `printf()`-style string to the end of the buffer.
66If this function fails it calls `curlx_dyn_free` on `dynbuf`.
68## `curlx_dyn_vaddf`
70```c
71CURLcode curlx_dyn_vaddf(struct dynbuf *s, const char *fmt, va_list ap);
72```
74Append a `vprintf()`-style string to the end of the buffer.
76If this function fails it calls `curlx_dyn_free` on `dynbuf`.
78## `curlx_dyn_reset`
80```c
81void curlx_dyn_reset(struct dynbuf *s);
82```
84Reset the buffer length, but leave the allocation.
86## `curlx_dyn_tail`
88```c
89CURLcode curlx_dyn_tail(struct dynbuf *s, size_t length);
90```
92Keep `length` bytes of the buffer tail (the last `length` bytes of the
93buffer). The rest of the buffer is dropped. The specified `length` must not be
94larger than the buffer length. To instead keep the leading part, see
95`curlx_dyn_setlen()`.
97## `curlx_dyn_ptr`
99```c
100char *curlx_dyn_ptr(const struct dynbuf *s);
101```
103Returns a `char *` to the buffer if it has a length, otherwise may return
104NULL. Since the buffer may be reallocated, this pointer should not be trusted
105or used anymore after the next buffer manipulation call.
107## `curlx_dyn_uptr`
109```c
110unsigned char *curlx_dyn_uptr(const struct dynbuf *s);
111```
113Returns an `unsigned char *` to the buffer if it has a length, otherwise may
114return NULL. Since the buffer may be reallocated, this pointer should not be
115trusted or used anymore after the next buffer manipulation call.
117## `curlx_dyn_len`
119```c
120size_t curlx_dyn_len(const struct dynbuf *s);
121```
123Returns the length of the buffer in bytes. Does not include the
124null-terminator byte.
126## `curlx_dyn_setlen`
128```c
129CURLcode curlx_dyn_setlen(struct dynbuf *s, size_t len);
130```
132Sets the new shorter length of the buffer in number of bytes. Keeps the
133leftmost set number of bytes, discards the rest. To instead keep the tail part
134of the buffer, see `curlx_dyn_tail()`.
136## `curlx_dyn_take`
138```c
139char *curlx_dyn_take(struct dynbuf *s, size_t *plen);
140```
142Transfers ownership of the internal buffer to the caller. The dynbuf
143resets to its initial state. The returned pointer may be `NULL` if the
144dynbuf never allocated memory. The returned length is the amount of
145data written to the buffer. The actual allocated memory might be larger.
Diagnostics4 git calls · 31 ms
CallStatusSizeTime031 ms
discover200152 B3 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=152
git.server.agent=gitty/1.0
git.server.object_format=sha1
git.server.caps=agent ls-refs fetch object-format
git.server.fetch=shallow filter sideband-all
git.protocol.version=2
git.pkt.frames=8
git.pkt.data=6
git.pkt.flush=2
git.pkt.delim=0
git.pkt.bytes=152
git.pkt.payload.max=34
ls-refs200149 B · hit3 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=3
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=3
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=149
git.pkt.payload.max=78
git.ls_refs.count=2
git.ls_refs.head=refs/heads/master
fetchblob:none · deepen 10200287 KiB · hit3 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=3
git.response.bytes=293470
git.response.cache=HIT
git.response.duration_ms=3
git.fetch.filter=blob:none
git.fetch.filter.requested=tree:0
git.fetch.filter.fallback=blob:none
git.fetch.filter.learned=false
git.fetch.wants=31c911efe5652725e930f4d2e60c9060e5f6646d
git.fetch.haves.count=0
git.fetch.deepen=10
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=10
git.pkt.data=8
git.pkt.flush=1
git.pkt.delim=1
git.pkt.bytes=293470
git.pkt.payload.max=65516
git.sideband.band1.bytes=293354
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0
git.pack.objects=87
git.pack.bytes=293354
git.pack.ofs_delta=0
git.pack.ref_delta=1
git.pack.chain.max=1
git.pack.trailer=6a646bcda6740bab42e321b51998b52ea15146c0
git.pack.full=86
Open pack map
fetch2001.3 KiB · hit25 ms
git.upload-pack fetch
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=fetch
git.upstream.dur_ms=25
git.response.bytes=1369
git.response.cache=HIT
git.response.duration_ms=25
git.fetch.wants=d28b02809dc9a52719cb1564b501f838104d416c
git.fetch.haves.count=0
git.fetch.deepen=0
git.fetch.thin_pack=false
git.fetch.ofs_delta=true
git.protocol.version=2
git.pkt.frames=3
git.pkt.data=2
git.pkt.flush=1
git.pkt.delim=0
git.pkt.bytes=1369
git.pkt.payload.max=1348
git.sideband.band1.bytes=1347
git.sideband.band2.bytes=0
git.sideband.band3.bytes=0

Each row is one HTTP round trip ply made to the git server for this page, on one timeline. discover asks what the server speaks, ls-refs lists branch tips, fetch brings objects by id. A hit was served by Workers Cache. Tap a row for its wire details.

Remote
https://5ad2236b39de4c8bd8f6270ea63f3ea9.artifacts.cloudflare.net/git/public-v0/curl.git
Ref
refs/heads/master
Commit
31c911efe5652725e930f4d2e60c9060e5f6646d
cf-ray
a5e2cebc9a2befad
Request
e1699fb6…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format