Artifactspublic-v0

curl

master
ply4 git calls31 ms288 KiB3 cachedprotocol v2
104 lines2.6 KiBRaw

bufref

This is an internal module for handling buffer references. A referenced buffer is associated with its destructor function that is implicitly called when the reference is invalidated. Once referenced, a buffer cannot be reallocated.

A data length is stored within the reference for binary data handling purposes; it is not used by the bufref API.

The struct bufref is used to hold data referencing a buffer. The members of that structure MUST NOT be accessed or modified without using the dedicated bufref API.

init

c
void Curl_bufref_init(struct bufref *br);

Initializes a bufref structure. This function MUST be called before any other operation is performed on the structure.

Upon completion, the referenced buffer is NULL and length is zero.

This function may also be called to bypass referenced buffer destruction while invalidating the current reference.

free

c
void Curl_bufref_free(struct bufref *br);

Destroys the previously referenced buffer using its destructor and reinitializes the structure for a possible subsequent reuse.

set

c
void Curl_bufref_set(struct bufref *br, const void *buffer, size_t length,
                     void (*destructor)(void *));

Releases the previously referenced buffer, then assigns the new buffer to the structure, associated with its destructor function. The latter can be specified as NULL: this is the case when the referenced buffer is static.

if buffer is NULL, length must be zero.

memdup0

c
CURLcode Curl_bufref_memdup0(struct bufref *br, const void *data,
                             size_t length);

Releases the previously referenced buffer, then duplicates the length-byte data into a buffer allocated via malloc() and references the latter associated with destructor curl_free().

An additional trailing byte is allocated and set to zero as a possible string null-terminator; it is not counted in the stored length.

Returns CURLE_OK if successful, else CURLE_OUT_OF_MEMORY.

ptr

c
const char *Curl_bufref_ptr(const struct bufref *br);

Returns a const char * to the referenced buffer.

uptr

c
const unsigned char *Curl_bufref_uptr(const struct bufref *br);

Returns a const unsigned char * to the referenced buffer.

len

c
size_t Curl_bufref_len(const struct bufref *br);

Returns the stored length of the referenced buffer.

dup

c
char *Curl_bufref_dup(const struct bufref *br);

Returns a strdup() version of the buffer. Note that this assumes that the bufref is null-terminated.

1<!--
2Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
4SPDX-License-Identifier: curl
5-->
7# bufref
9This is an internal module for handling buffer references. A referenced
10buffer is associated with its destructor function that is implicitly called
11when the reference is invalidated. Once referenced, a buffer cannot be
12reallocated.
14A data length is stored within the reference for binary data handling
15purposes; it is not used by the bufref API.
17The `struct bufref` is used to hold data referencing a buffer. The members of
18that structure **MUST NOT** be accessed or modified without using the dedicated
19bufref API.
21## `init`
23```c
24void Curl_bufref_init(struct bufref *br);
25```
27Initializes a `bufref` structure. This function **MUST** be called before any
28other operation is performed on the structure.
30Upon completion, the referenced buffer is `NULL` and length is zero.
32This function may also be called to bypass referenced buffer destruction while
33invalidating the current reference.
35## `free`
37```c
38void Curl_bufref_free(struct bufref *br);
39```
41Destroys the previously referenced buffer using its destructor and
42reinitializes the structure for a possible subsequent reuse.
44## `set`
46```c
47void Curl_bufref_set(struct bufref *br, const void *buffer, size_t length,
48 void (*destructor)(void *));
49```
51Releases the previously referenced buffer, then assigns the new `buffer` to
52the structure, associated with its `destructor` function. The latter can be
53specified as `NULL`: this is the case when the referenced buffer is static.
55if `buffer` is NULL, `length` must be zero.
57## `memdup0`
59```c
60CURLcode Curl_bufref_memdup0(struct bufref *br, const void *data,
61 size_t length);
62```
64Releases the previously referenced buffer, then duplicates the `length`-byte
65`data` into a buffer allocated via `malloc()` and references the latter
66associated with destructor `curl_free()`.
68An additional trailing byte is allocated and set to zero as a possible string
69null-terminator; it is not counted in the stored length.
71Returns `CURLE_OK` if successful, else `CURLE_OUT_OF_MEMORY`.
73## `ptr`
75```c
76const char *Curl_bufref_ptr(const struct bufref *br);
77```
79Returns a `const char *` to the referenced buffer.
81## `uptr`
83```c
84const unsigned char *Curl_bufref_uptr(const struct bufref *br);
85```
87Returns a `const unsigned char *` to the referenced buffer.
89## `len`
91```c
92size_t Curl_bufref_len(const struct bufref *br);
93```
95Returns the stored length of the referenced buffer.
97## `dup`
99```c
100char *Curl_bufref_dup(const struct bufref *br);
101```
103Returns a strdup() version of the buffer. Note that this assumes that the
104bufref is null-terminated.
Diagnostics4 git calls · 31 ms
CallStatusSizeTime031 ms
discover200152 B2 ms
git.upload-pack discover
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
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 · hit2 ms
git.upload-pack ls-refs
http.response.status_code=200
git.upstream.cf_ray=-
git.upstream.phase=ls-refs
git.upstream.dur_ms=2
git.response.bytes=149
git.response.cache=HIT
git.response.duration_ms=2
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 · hit4 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=4
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.1 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=1129
git.response.cache=HIT
git.response.duration_ms=25
git.fetch.wants=09413dea03b39ac345a2c38baac1158d37cabb84
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=1129
git.pkt.payload.max=1108
git.sideband.band1.bytes=1107
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
a5e2baaaeb66cf46
Request
f5456881…
Protocol
v2 · sha1
Agent
gitty/1.0
Filter
advertised
Fetch
shallow filter sideband-all
Capabilities
agent ls-refs fetch object-format