MCPcopy Create free account
hub / github.com/buke/quickjs-go / dbuf_printf

Function dbuf_printf

deps/quickjs/cutils.h:840–862  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

838}
839
840static inline int JS_PRINTF_FORMAT_ATTR(2, 3) dbuf_printf(DynBuf *s, JS_PRINTF_FORMAT const char *fmt, ...)
841{
842 va_list ap;
843 char buf[128];
844 int len;
845
846 va_start(ap, fmt);
847 len = vsnprintf(buf, sizeof(buf), fmt, ap);
848 va_end(ap);
849 if (len < (int)sizeof(buf)) {
850 /* fast case */
851 return dbuf_put(s, (uint8_t *)buf, len);
852 } else {
853 if (dbuf_claim(s, len + 1))
854 return -1;
855 va_start(ap, fmt);
856 vsnprintf((char *)(s->buf + s->size), s->allocated_size - s->size,
857 fmt, ap);
858 va_end(ap);
859 s->size += len;
860 }
861 return 0;
862}
863
864static inline void dbuf_free(DynBuf *s)
865{

Callers 3

js_printf_internalFunction · 0.85
js_std_urlGetFunction · 0.85
js_printFunction · 0.85

Calls 2

dbuf_putFunction · 0.85
dbuf_claimFunction · 0.85

Tested by

no test coverage detected