summaryrefslogtreecommitdiff
path: root/src/mwindow.c
diff options
context:
space:
mode:
authorCarlos Martin Nieto <cmn@elego.de>2012-06-28 12:05:49 +0200
committerCarlos Martin Nieto <cmn@elego.de>2012-06-28 12:10:33 +0200
commit1d8943c640bad4425b8578aae6f680fa8e513bc7 (patch)
tree1449d930980d07f5c7a1c12d1f9b0c63b41ba4ab /src/mwindow.c
parent1de44c24936ecf39915913ddf26f68f78c7963d3 (diff)
downloadlibgit2-1d8943c640bad4425b8578aae6f680fa8e513bc7.tar.gz
mwindow: allow memory-window files to deregister
Once a file is registered, there is no way to deregister it, even after the structure that contains it is no longer needed and has been freed. This may be the source of #624. Allow and use the deregister function to remove our file from the global list.
Diffstat (limited to 'src/mwindow.c')
-rw-r--r--src/mwindow.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/src/mwindow.c b/src/mwindow.c
index 74fbf7834..1a5446b9c 100644
--- a/src/mwindow.c
+++ b/src/mwindow.c
@@ -261,6 +261,23 @@ int git_mwindow_file_register(git_mwindow_file *mwf)
return git_vector_insert(&ctl->windowfiles, mwf);
}
+int git_mwindow_file_deregister(git_mwindow_file *mwf)
+{
+ git_mwindow_ctl *ctl = &GIT_GLOBAL->mem_ctl;
+ git_mwindow_file *cur;
+ unsigned int i;
+
+ git_vector_foreach(&ctl->windowfiles, i, cur) {
+ if (cur == mwf) {
+ git_vector_remove(&ctl->windowfiles, i);
+ return 0;
+ }
+ }
+
+ giterr_set(GITERR_ODB, "Failed to find the memory window file to deregister");
+ return -1;
+}
+
void git_mwindow_close(git_mwindow **window)
{
git_mwindow *w = *window;