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

Function walker_targets_stdin

walker.c:241–268  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

239}
240
241int walker_targets_stdin(char ***target, const char ***write_ref)
242{
243 int targets = 0, targets_alloc = 0;
244 struct strbuf buf = STRBUF_INIT;
245 *target = NULL; *write_ref = NULL;
246 while (1) {
247 char *rf_one = NULL;
248 char *tg_one;
249
250 if (strbuf_getline_lf(&buf, stdin) == EOF)
251 break;
252 tg_one = buf.buf;
253 rf_one = strchr(tg_one, '\t');
254 if (rf_one)
255 *rf_one++ = 0;
256
257 if (targets >= targets_alloc) {
258 targets_alloc = targets_alloc ? targets_alloc * 2 : 64;
259 REALLOC_ARRAY(*target, targets_alloc);
260 REALLOC_ARRAY(*write_ref, targets_alloc);
261 }
262 (*target)[targets] = xstrdup(tg_one);
263 (*write_ref)[targets] = xstrdup_or_null(rf_one);
264 targets++;
265 }
266 strbuf_release(&buf);
267 return targets;
268}
269
270void walker_targets_free(int targets, char **target, const char **write_ref)
271{

Callers 1

cmd_mainFunction · 0.85

Calls 4

strbuf_getline_lfFunction · 0.85
xstrdupFunction · 0.85
xstrdup_or_nullFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected