| 156 | } |
| 157 | |
| 158 | int 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 | |
| 179 | void read_mmblob(mmfile_t *ptr, struct object_database *odb, |
| 180 | const struct object_id *oid) |
no test coverage detected