summaryrefslogtreecommitdiff
path: root/src/mwindow.c
diff options
context:
space:
mode:
authorRussell Belfer <arrbee@arrbee.com>2012-03-16 15:56:01 -0700
committerRussell Belfer <arrbee@arrbee.com>2012-03-16 15:56:01 -0700
commit0d0fa7c3681e4ef3d0452666a9bc97d4b08391c9 (patch)
tree5e03e03bf9dc2f6125f4fb450cd3239d882b824f /src/mwindow.c
parent4cfe2ab60b1e26554b2bf753b06f538cb3475bd0 (diff)
downloadlibgit2-0d0fa7c3681e4ef3d0452666a9bc97d4b08391c9.tar.gz
Convert attr, ignore, mwindow, status to new errors
Also cleaned up some previously converted code that still had little things to polish.
Diffstat (limited to 'src/mwindow.c')
-rw-r--r--src/mwindow.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/mwindow.c b/src/mwindow.c
index cde24d1b1..7fe02b9ce 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -115,7 +115,7 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
unsigned int i;
git_mwindow *lru_w = NULL, *lru_l = NULL, **list = &mwf->windows;
- /* FIMXE: Does this give us any advantage? */
+ /* FIXME: Does this give us any advantage? */
if(mwf->windows)
git_mwindow_scan_lru(mwf, &lru_w, &lru_l);
@@ -127,22 +127,23 @@ static int git_mwindow_close_lru(git_mwindow_file *mwf)
list = &cur->windows;
}
- if (lru_w) {
- ctl->mapped -= lru_w->window_map.len;
- git_futils_mmap_free(&lru_w->window_map);
+ if (!lru_w) {
+ giterr_set(GITERR_OS, "Failed to close memory window. Couldn't find LRU");
+ return -1;
+ }
- if (lru_l)
- lru_l->next = lru_w->next;
- else
- *list = lru_w->next;
+ ctl->mapped -= lru_w->window_map.len;
+ git_futils_mmap_free(&lru_w->window_map);
- git__free(lru_w);
- ctl->open_windows--;
+ if (lru_l)
+ lru_l->next = lru_w->next;
+ else
+ *list = lru_w->next;
- return GIT_SUCCESS;
- }
+ git__free(lru_w);
+ ctl->open_windows--;
- return git__throw(GIT_ERROR, "Failed to close memory window. Couln't find LRU");
+ return 0;
}
static git_mwindow *new_window(
@@ -158,7 +159,7 @@ static git_mwindow *new_window(
w = git__malloc(sizeof(*w));
if (w == NULL)
- return w;
+ return NULL;
memset(w, 0x0, sizeof(*w));
w->offset = (offset / walign) * walign;
@@ -170,7 +171,7 @@ static git_mwindow *new_window(
ctl->mapped += (size_t)len;
while (_mw_options.mapped_limit < ctl->mapped &&
- git_mwindow_close_lru(mwf) == GIT_SUCCESS) /* nop */;
+ git_mwindow_close_lru(mwf) == 0) /* nop */;
/*
* We treat _mw_options.mapped_limit as a soft limit. If we can't find a