master
1/***************************************************************************
2 * _ _ ____ _
3 * Project ___| | | | _ \| |
4 * / __| | | | |_) | |
5 * | (__| |_| | _ <| |___
6 * \___|\___/|_| \_\_____|
7 *
8 * Copyright (C) Daniel Stenberg, <daniel@haxx.se>, et al.
9 *
10 * This software is licensed as described in the file COPYING, which
11 * you should have received as part of this distribution. The terms
12 * are also available at https://curl.se/docs/copyright.html.
13 *
14 * You may opt to use, copy, modify, merge, publish, distribute and/or sell
15 * copies of the Software, and permit persons to whom the Software is
16 * furnished to do so, under the terms of the COPYING file.
17 *
18 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
19 * KIND, either express or implied.
20 *
21 * SPDX-License-Identifier: curl
22 *
23 ***************************************************************************/
24#include "curl_setup.h"
26#include "slist.h"
28/* returns last node in linked list */
29static struct curl_slist *slist_get_last(struct curl_slist *list)
30{
31 struct curl_slist *item;
33 /* if caller passed us a NULL, return now */
34 if(!list)
35 return NULL;
37 /* loop through to find the last item */
38 item = list;
39 while(item->next) {
40 item = item->next;
41 }
42 return item;
43}
45/*
46 * Curl_slist_append_nodup() appends a string to the linked list. Rather than
47 * copying the string in dynamic storage, it takes its ownership. The string
48 * should have been malloc()ated. Curl_slist_append_nodup always returns
49 * the address of the first record, so that you can use this function as an
50 * initialization function as well as an append function.
51 * If an error occurs, NULL is returned and the string argument is NOT
52 * released.
53 */
54struct curl_slist *Curl_slist_append_nodup(struct curl_slist *list,
55 const char *data)
56{
57 struct curl_slist *last;
58 struct curl_slist *new_item;
60 DEBUGASSERT(data);
62 new_item = curlx_malloc(sizeof(struct curl_slist));
63 if(!new_item)
64 return NULL;
66 new_item->next = NULL;
67 new_item->data = CURL_UNCONST(data);
69 /* if this is the first item, then new_item *is* the list */
70 if(!list)
71 return new_item;
73 last = slist_get_last(list);
74 last->next = new_item;
75 return list;
76}
78/*
79 * curl_slist_append() appends a string to the linked list. It always returns
80 * the address of the first record, so that you can use this function as an
81 * initialization function as well as an append function. If you find this
82 * bothersome, then create a separate _init function and call it
83 * appropriately from within the program.
84 */
85struct curl_slist *curl_slist_append(struct curl_slist *list, const char *data)
86{
87 char *dupdata = curlx_strdup(data);
89 if(!dupdata)
90 return NULL;
92 list = Curl_slist_append_nodup(list, dupdata);
93 if(!list)
94 curlx_free(dupdata);
96 return list;
97}
99/*
100 * Curl_slist_duplicate() duplicates a linked list. It always returns the
101 * address of the first record of the cloned list or NULL in case of an
102 * error (or if the input list was NULL).
103 */
104struct curl_slist *Curl_slist_duplicate(struct curl_slist *inlist)
105{
106 struct curl_slist *outlist = NULL;
107 struct curl_slist **tail = &outlist;
109 while(inlist) {
110 struct curl_slist *tmp = curl_slist_append(NULL, inlist->data);
112 if(!tmp) {
113 curl_slist_free_all(outlist);
114 return NULL;
115 }
117 *tail = tmp;
118 tail = &tmp->next;
119 inlist = inlist->next;
120 }
121 return outlist;
122}
124/* be nice and clean up resources */
125void curl_slist_free_all(struct curl_slist *list)
126{
127 struct curl_slist *next;
128 struct curl_slist *item;
130 if(!list)
131 return;
133 item = list;
134 do {
135 next = item->next;
136 curlx_safefree(item->data);
137 curlx_free(item);
138 item = next;
139 } while(next);
140}
Diagnostics4 git calls · 27 ms
CallStatusSizeTime027 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 · 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=86Open pack map
fetch2001.5 KiB · hit22 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=22 git.response.bytes=1496 git.response.cache=HIT git.response.duration_ms=22 git.fetch.wants=c642a60763522e9513911b26f504d5f1cede5b91 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=1496 git.pkt.payload.max=1475 git.sideband.band1.bytes=1474 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
- a5e14803f927a140
- Request
- b52a4dcf…
- Protocol
- v2 · sha1
- Agent
- gitty/1.0
- Filter
- advertised
- Fetch
- shallow filter sideband-all
- Capabilities
- agent ls-refs fetch object-format