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

Function strbuf_readlink

strbuf.c:581–607  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

579#define STRBUF_MAXLINK (32767)
580
581int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint)
582{
583 size_t oldalloc = sb->alloc;
584
585 if (hint < 32)
586 hint = 32;
587
588 while (hint < STRBUF_MAXLINK) {
589 ssize_t len;
590
591 strbuf_grow(sb, hint + 1);
592 len = readlink(path, sb->buf, hint + 1);
593 if (len < 0) {
594 if (errno != ERANGE)
595 break;
596 } else if (len <= hint) {
597 strbuf_setlen(sb, len);
598 return 0;
599 }
600
601 /* .. the buffer was too small - try again */
602 hint *= 2;
603 }
604 if (oldalloc == 0)
605 strbuf_release(sb);
606 return -1;
607}
608
609int strbuf_getcwd(struct strbuf *sb)
610{

Callers 15

copy_templates_1Function · 0.85
index_pathFunction · 0.85
fake_working_tree_commitFunction · 0.85
show_patch_diffFunction · 0.85
resolve_symlinkFunction · 0.85
read_old_dataFunction · 0.85
diff_populate_filespecFunction · 0.85
prepare_temp_fileFunction · 0.85
ce_compare_linkFunction · 0.85
strbuf_realpath_1Function · 0.85
fsmonitor__get_aliasFunction · 0.85

Calls 4

strbuf_growFunction · 0.85
readlinkFunction · 0.85
strbuf_setlenFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by 1

cmd__path_utilsFunction · 0.68