Release pack windows before reporting out of memory.
[gitweb.git] / sha1_file.c
index 8de8ce0a728bb5df75557d85c2ad0d55648af90d..fb1032b0fdf9f778441c49664da4f5f6b5da57f5 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;