MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / strbuf_init

Function strbuf_init

deps/lua/src/strbuf.c:44–66  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

42}
43
44void strbuf_init(strbuf_t *s, int len)
45{
46 int size;
47
48 if (len <= 0)
49 size = STRBUF_DEFAULT_SIZE;
50 else
51 size = len + 1; /* \0 terminator */
52
53 s->buf = NULL;
54 s->size = size;
55 s->length = 0;
56 s->increment = STRBUF_DEFAULT_INCREMENT;
57 s->dynamic = 0;
58 s->reallocs = 0;
59 s->debug = 0;
60
61 s->buf = malloc(size);
62 if (!s->buf)
63 die("Out of memory");
64
65 strbuf_ensure_null(s);
66}
67
68strbuf_t *strbuf_new(int len)
69{

Callers 4

json_create_configFunction · 0.85
json_encodeFunction · 0.85
strbuf_newFunction · 0.85

Calls 3

mallocFunction · 0.85
dieFunction · 0.85
strbuf_ensure_nullFunction · 0.85

Tested by

no test coverage detected