MCPcopy Create free account
hub / github.com/Snapchat/Valdi / dbuf_printf

Function dbuf_printf

third-party/quickjs/src/quickjs/cutils.c:169–192  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

167}
168
169int __attribute__((format(printf, 2, 3))) dbuf_printf(DynBuf *s,
170 const char *fmt, ...)
171{
172 va_list ap;
173 char buf[128];
174 int len;
175
176 va_start(ap, fmt);
177 len = vsnprintf(buf, sizeof(buf), fmt, ap);
178 va_end(ap);
179 if (len < sizeof(buf)) {
180 /* fast case */
181 return dbuf_put(s, (uint8_t *)buf, len);
182 } else {
183 if (dbuf_realloc(s, s->size + len + 1))
184 return -1;
185 va_start(ap, fmt);
186 vsnprintf((char *)(s->buf + s->size), s->allocated_size - s->size,
187 fmt, ap);
188 va_end(ap);
189 s->size += len;
190 }
191 return 0;
192}
193
194void dbuf_free(DynBuf *s)
195{

Callers 1

bf_ftoa_internalFunction · 0.85

Calls 2

dbuf_putFunction · 0.85
dbuf_reallocFunction · 0.85

Tested by

no test coverage detected