MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / msprintf

Function msprintf

extern/btyacc/mstring.c:11–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9#define TAIL 8
10
11void msprintf(struct mstring *s, const char *fmt, ...)
12{
13static char buf[4096]; /* a big static buffer */
14va_list args;
15int len;
16
17 if (!s || !s->base) return;
18 va_start(args, fmt);
19 vsprintf(buf, fmt, args);
20 va_end(args);
21
22 len = strlen(buf);
23 if (len > (s->end - s->ptr)) {
24 int cp = s->ptr - s->base, cl = s->end - s->base, nl = cl;
25 while (len > (nl - cp))
26 nl = nl + nl + TAIL;
27 if ((s->base = realloc(s->base, nl))) {
28 s->ptr = s->base + cp;
29 s->end = s->base + nl; }
30 else {
31 s->ptr = s->end = 0;
32 return; } }
33 memcpy(s->ptr, buf, len);
34 s->ptr += len;
35}
36
37int mputchar(struct mstring *s, int ch)
38{

Callers 1

compile_argFunction · 0.85

Calls 1

vsprintfFunction · 0.85

Tested by

no test coverage detected