summaryrefslogtreecommitdiff
path: root/sha1_file.c
diff options
context:
space:
mode:
authorJonathan Tan <jonathantanmy@google.com>2017-08-18 22:20:20 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-08-23 22:12:06 (GMT)
commitf0e17e86e1b1030b2719f3d6e9d4124c9b5bc480 (patch)
tree8bbe6ceefe3fa6bdd8f5325925cb6319deeca1e5 /sha1_file.c
parent0317f45576a0b48c90c4b023fa572a000633946c (diff)
downloadgit-f0e17e86e1b1030b2719f3d6e9d4124c9b5bc480.zip
git-f0e17e86e1b1030b2719f3d6e9d4124c9b5bc480.tar.gz
git-f0e17e86e1b1030b2719f3d6e9d4124c9b5bc480.tar.bz2
pack: move release_pack_memory()
The function unuse_one_window() needs to be temporarily made global. Its scope will be restored to static in a subsequent commit. Signed-off-by: Jonathan Tan <jonathantanmy@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'sha1_file.c')
-rw-r--r--sha1_file.c49
1 files changed, 0 insertions, 49 deletions
diff --git a/sha1_file.c b/sha1_file.c
index 084fe29..dce232f 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -681,55 +681,6 @@ static int has_loose_object(const unsigned char *sha1)
return check_and_freshen(sha1, 0);
}
-static void scan_windows(struct packed_git *p,
- struct packed_git **lru_p,
- struct pack_window **lru_w,
- struct pack_window **lru_l)
-{
- struct pack_window *w, *w_l;
-
- for (w_l = NULL, w = p->windows; w; w = w->next) {
- if (!w->inuse_cnt) {
- if (!*lru_w || w->last_used < (*lru_w)->last_used) {
- *lru_p = p;
- *lru_w = w;
- *lru_l = w_l;
- }
- }
- w_l = w;
- }
-}
-
-static int unuse_one_window(struct packed_git *current)
-{
- struct packed_git *p, *lru_p = NULL;
- struct pack_window *lru_w = NULL, *lru_l = NULL;
-
- if (current)
- scan_windows(current, &lru_p, &lru_w, &lru_l);
- for (p = packed_git; p; p = p->next)
- scan_windows(p, &lru_p, &lru_w, &lru_l);
- if (lru_p) {
- munmap(lru_w->base, lru_w->len);
- pack_mapped -= lru_w->len;
- if (lru_l)
- lru_l->next = lru_w->next;
- else
- lru_p->windows = lru_w->next;
- free(lru_w);
- pack_open_windows--;
- return 1;
- }
- return 0;
-}
-
-void release_pack_memory(size_t need)
-{
- size_t cur = pack_mapped;
- while (need >= (cur - pack_mapped) && unuse_one_window(NULL))
- ; /* nothing */
-}
-
static void mmap_limit_check(size_t length)
{
static size_t limit = 0;