MCPcopy Create free account
hub / github.com/git/git / read_mmfile

Function read_mmfile

xdiff-interface.c:158–177  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

156}
157
158int read_mmfile(mmfile_t *ptr, const char *filename)
159{
160 struct stat st;
161 FILE *f;
162 size_t sz;
163
164 if (stat(filename, &st))
165 return error_errno("Could not stat %s", filename);
166 if (!(f = fopen(filename, "rb")))
167 return error_errno("Could not open %s", filename);
168 sz = xsize_t(st.st_size);
169 ptr->ptr = xmalloc(sz ? sz : 1);
170 if (sz && fread(ptr->ptr, sz, 1, f) != 1) {
171 fclose(f);
172 return error("Could not read %s", filename);
173 }
174 fclose(f);
175 ptr->size = sz;
176 return 0;
177}
178
179void read_mmblob(mmfile_t *ptr, struct object_database *odb,
180 const struct object_id *oid)

Callers 5

try_mergeFunction · 0.85
mergeFunction · 0.85
rerere_forget_one_pathFunction · 0.85
cmd_merge_fileFunction · 0.85
diff_twoFunction · 0.85

Calls 5

error_errnoFunction · 0.85
xsize_tFunction · 0.85
errorFunction · 0.85
statClass · 0.70
xmallocFunction · 0.70

Tested by

no test coverage detected