@matheusbsbs / matheus-bagliano / commits / 4147d801db
Fork 0

discard_cache(): discard index, even if no file was mmap()ed

Since add_cacheinfo() can be called without a mapped index file, discard_cache() _has_ to discard the entries, even when cache_mmap == NULL. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <junkio@cox.net>

Johannes Schindelin committed Aug 10, 2006 at 16:47 UTC 4147d801db66df9b127ffe315601f467aa9d1c48
1 file changed +3 -3
read-cache.c
+3 -3
@@ -840,14 +840,14 @@ int discard_cache()
840 {
841 int ret;
842
843 + active_nr = active_cache_changed = 0;
844 + index_file_timestamp = 0;
845 + cache_tree_free(&active_cache_tree);
846 if (cache_mmap == NULL)
847 return 0;
848 ret = munmap(cache_mmap, cache_mmap_size);
849 cache_mmap = NULL;
850 cache_mmap_size = 0;
848 - active_nr = active_cache_changed = 0;
849 - index_file_timestamp = 0;
850 - cache_tree_free(&active_cache_tree);
851
852 /* no need to throw away allocated active_cache */
853 return ret;