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

Function map_fd

object-file.c:149–166  ·  view source on GitHub ↗

* Map and close the given loose object fd. The path argument is used for * error reporting. */

Source from the content-addressed store, hash-verified

147 * error reporting.
148 */
149static void *map_fd(int fd, const char *path, unsigned long *size)
150{
151 void *map = NULL;
152 struct stat st;
153
154 if (!fstat(fd, &st)) {
155 *size = xsize_t(st.st_size);
156 if (!*size) {
157 /* mmap() is forbidden on empty files */
158 error(_("object file %s is empty"), path);
159 close(fd);
160 return NULL;
161 }
162 map = xmmap(NULL, *size, PROT_READ, MAP_PRIVATE, fd, 0);
163 }
164 close(fd);
165 return map;
166}
167
168enum unpack_loose_header_result unpack_loose_header(git_zstream *stream,
169 unsigned char *map,

Callers 1

read_loose_objectFunction · 0.85

Calls 3

xsize_tFunction · 0.85
errorFunction · 0.85
xmmapFunction · 0.85

Tested by

no test coverage detected