Merge branch 'jn/thinner-wrapper'
* jn/thinner-wrapper: Remove pack file handling dependency from wrapper.o pack-objects: mark file-local variable static wrapper: give zlib wrappers their own translation unit strbuf: move strbuf_branchname to sha1_name.c path helpers: move git_mkstemp* to wrapper.c wrapper: move odb_* to environment.c wrapper: move xmmap() to sha1_file.c
This commit is contained in:
26
sha1_file.c
26
sha1_file.c
@ -578,6 +578,21 @@ void release_pack_memory(size_t need, int fd)
|
||||
; /* nothing */
|
||||
}
|
||||
|
||||
void *xmmap(void *start, size_t length,
|
||||
int prot, int flags, int fd, off_t offset)
|
||||
{
|
||||
void *ret = mmap(start, length, prot, flags, fd, offset);
|
||||
if (ret == MAP_FAILED) {
|
||||
if (!length)
|
||||
return NULL;
|
||||
release_pack_memory(length, fd);
|
||||
ret = mmap(start, length, prot, flags, fd, offset);
|
||||
if (ret == MAP_FAILED)
|
||||
die_errno("Out of memory? mmap failed");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void close_pack_windows(struct packed_git *p)
|
||||
{
|
||||
while (p->windows) {
|
||||
@ -803,11 +818,22 @@ static struct packed_git *alloc_packed_git(int extra)
|
||||
return p;
|
||||
}
|
||||
|
||||
static void try_to_free_pack_memory(size_t size)
|
||||
{
|
||||
release_pack_memory(size, -1);
|
||||
}
|
||||
|
||||
struct packed_git *add_packed_git(const char *path, int path_len, int local)
|
||||
{
|
||||
static int have_set_try_to_free_routine;
|
||||
struct stat st;
|
||||
struct packed_git *p = alloc_packed_git(path_len + 2);
|
||||
|
||||
if (!have_set_try_to_free_routine) {
|
||||
have_set_try_to_free_routine = 1;
|
||||
set_try_to_free_routine(try_to_free_pack_memory);
|
||||
}
|
||||
|
||||
/*
|
||||
* Make sure a corresponding .pack file exists and that
|
||||
* the index looks sane.
|
||||
|
Reference in New Issue
Block a user