MCPcopy Create free account
hub / github.com/antirez/ds4 / buf_printf

Function buf_printf

ds4_server.c:145–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143static void buf_putc(buf *b, char c) {
144 buf_append(b, &c, 1);
145}
146
147static void buf_puts(buf *b, const char *s) {
148 buf_append(b, s, strlen(s));
149}
150
151static void buf_printf(buf *b, const char *fmt, ...) {
152 va_list ap;
153 va_start(ap, fmt);
154 va_list ap2;
155 va_copy(ap2, ap);
156 int n = vsnprintf(NULL, 0, fmt, ap);
157 va_end(ap);
158 if (n < 0) die("vsnprintf failed");
159 buf_reserve(b, (size_t)n);
160 vsnprintf(b->ptr + b->len, b->cap - b->len, fmt, ap2);

Callers 15

json_escapeFunction · 0.85
json_escape_fragment_nFunction · 0.85
http_responseFunction · 0.85
sse_chunkFunction · 0.85
append_openai_usage_jsonFunction · 0.85
sse_usage_chunkFunction · 0.85
sse_chat_finishFunction · 0.85
sse_chat_delta_nFunction · 0.85

Calls 2

buf_reserveFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected