Codebergdnkl
foot
master
1#include <errno.h>
2#include <stdint.h>
3#include <stdio.h>
4#include <stdlib.h>
5#include "xmalloc.h"
6#include "debug.h"
8static void *
9check_alloc(void *alloc)
10{
11 FATAL_ERROR_ON(alloc == NULL, ENOMEM);
12 return alloc;
13}
15void *
16xmalloc(size_t size)
17{
18 return check_alloc(malloc(likely(size) ? size : 1));
19}
21void *
22xcalloc(size_t nmemb, size_t size)
23{
24 xassert(size != 0);
25 return check_alloc(calloc(likely(nmemb) ? nmemb : 1, size));
26}
28void *
29xrealloc(void *ptr, size_t size)
30{
31 xassert(size != 0);
32 return check_alloc(realloc(ptr, size));
33}
35// reallocarray(3) was only added to POSIX in Issue 8 (2024) and isn't
36// present on some platforms (e.g. Android API levels < 29), so this
37// function is both for portability and ENOMEM handling.
38void *
39xreallocarray(void *ptr, size_t nmemb, size_t size)
40{
41 FATAL_ERROR_ON(nmemb == 0 || size == 0, EINVAL);
42 FATAL_ERROR_ON(size > SIZE_MAX / nmemb, EOVERFLOW);
43 return xrealloc(ptr, nmemb * size);
44}
46char *
47xstrdup(const char *str)
48{
49 return check_alloc(strdup(str));
50}
52char *
53xstrndup(const char *str, size_t n)
54{
55 return check_alloc(strndup(str, n));
56}
58char32_t *
59xc32dup(const char32_t *str)
60{
61 return check_alloc(c32dup(str));
62}
64static VPRINTF(2) int
65xvasprintf_(char **strp, const char *format, va_list ap)
66{
67 va_list ap2;
68 va_copy(ap2, ap);
69 int n = vsnprintf(NULL, 0, format, ap2);
70 FATAL_ERROR_ON(n < 0, EILSEQ);
71 va_end(ap2);
72 *strp = xmalloc(n + 1);
73 return vsnprintf(*strp, n + 1, format, ap);
74}
76char *
77xvasprintf(const char *format, va_list ap)
78{
79 char *str;
80 xvasprintf_(&str, format, ap);
81 return str;
82}
84char *
85xasprintf(const char *format, ...)
86{
87 va_list ap;
88 va_start(ap, format);
89 char *str = xvasprintf(format, ap);
90 va_end(ap);
91 return str;
92}
Diagnostics5 git calls · 955 ms
CallStatusSizeTime0955 ms
discover200178 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=178 git.server.agent=git/2.56.1-Linux git.server.object_format=sha1 git.server.caps=agent ls-refs fetch server-option object-format git.server.fetch=shallow wait-for-done filter git.protocol.version=2 git.pkt.frames=9 git.pkt.data=7 git.pkt.flush=2 git.pkt.delim=0 git.pkt.bytes=178 git.pkt.payload.max=35
ls-refs20010 KiB491 ms
git.upload-pack ls-refs http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=ls-refs git.upstream.dur_ms=404 git.response.bytes=10322 git.response.cache=EXPIRED git.response.duration_ms=491 git.protocol.version=2 git.pkt.frames=108 git.pkt.data=107 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=10322 git.pkt.payload.max=106 git.ls_refs.count=107 git.ls_refs.head=refs/heads/master
fetchcombine:blob:none+tree:2 · deepen 12008.6 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=8830 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=combine:blob:none+tree:2 git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0 git.fetch.haves.count=0 git.fetch.deepen=1 git.fetch.thin_pack=false git.fetch.ofs_delta=true git.protocol.version=2 git.pkt.frames=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=8830 git.pkt.payload.max=8730 git.sideband.band1.bytes=8730 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=14 git.pack.bytes=8730 git.fetch.wide.objects=14 git.fetch.wide.extra_bytes=9909 git.fetch.wide.blobs=0
fetchtree:0 · deepen 102009.3 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=9489 git.response.cache=HIT git.response.duration_ms=3 git.fetch.filter=tree:0 git.fetch.wants=c0d2c3e95d74cb60526ff28aec9f34ee3df545e0 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=7 git.pkt.data=5 git.pkt.flush=1 git.pkt.delim=1 git.pkt.bytes=9489 git.pkt.payload.max=9389 git.sideband.band1.bytes=9389 git.sideband.band2.bytes=0 git.sideband.band3.bytes=0 git.pack.objects=10 git.pack.bytes=9389 git.pack.ofs_delta=0 git.pack.ref_delta=0 git.pack.chain.max=0 git.pack.trailer=de930681b6073ba5b599a0f956bfbd114762ad5a git.pack.full=10Open pack map
fetch200741 B461 ms
git.upload-pack fetch http.response.status_code=200 git.upstream.cf_ray=- git.upstream.phase=fetch git.upstream.dur_ms=461 git.response.bytes=741 git.response.cache=MISS git.response.duration_ms=461 git.fetch.wants=e60c1c6e1e6777d8ff23b16961f73a08521ff263 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=4 git.pkt.data=3 git.pkt.flush=1 git.pkt.delim=0 git.pkt.bytes=741 git.pkt.payload.max=714 git.sideband.band1.bytes=714 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://codeberg.org/dnkl/foot
- Ref
- refs/heads/master
- Commit
- c0d2c3e95d74cb60526ff28aec9f34ee3df545e0
- cf-ray
- a5e24510ddd9cf56
- Request
- 13fa080b…
- Protocol
- v2 · sha1
- Agent
- git/2.56.1-Linux
- Filter
- advertised
- Fetch
- shallow wait-for-done filter
- Capabilities
- agent ls-refs fetch server-option object-format