MCPcopy Index your code
hub / github.com/git/git / strbuf_split_buf

Function strbuf_split_buf

strbuf.c:180–205  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

178}
179
180struct strbuf **strbuf_split_buf(const char *str, size_t slen,
181 int terminator, int max)
182{
183 struct strbuf **ret = NULL;
184 size_t nr = 0, alloc = 0;
185 struct strbuf *t;
186
187 while (slen) {
188 int len = slen;
189 if (max <= 0 || nr + 1 < max) {
190 const char *end = memchr(str, terminator, slen);
191 if (end)
192 len = end - str + 1;
193 }
194 t = xmalloc(sizeof(struct strbuf));
195 strbuf_init(t, len);
196 strbuf_add(t, str, len);
197 ALLOC_GROW(ret, nr + 2, alloc);
198 ret[nr++] = t;
199 str += len;
200 slen -= len;
201 }
202 ALLOC_GROW(ret, nr + 1, alloc); /* In case string was empty */
203 ret[nr] = NULL;
204 return ret;
205}
206
207void strbuf_add_separated_string_list(struct strbuf *str,
208 const char *sep,

Callers 3

strbuf_split_strFunction · 0.85
strbuf_split_maxFunction · 0.85
trailer_block_getFunction · 0.85

Calls 3

strbuf_initFunction · 0.85
strbuf_addFunction · 0.85
xmallocFunction · 0.70

Tested by

no test coverage detected