Release pack windows before reporting out of memory.
[git/git.git] / sha1_file.c
index 8de8ce0..fb1032b 100644 (file)
@@ -522,6 +522,13 @@ static int unuse_one_window(struct packed_git *current)
        return 0;
 }
 
+void release_pack_memory(size_t need)
+{
+       size_t cur = pack_mapped;
+       while (need >= (cur - pack_mapped) && unuse_one_window(NULL))
+               ; /* nothing */
+}
+
 void unuse_pack(struct pack_window **w_cursor)
 {
        struct pack_window *w = *w_cursor;