Skip to content

Commit

Permalink
discard_cache(): discard index, even if no file was mmap()ed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Aug 10, 2006
1 parent 984b657 commit 4147d80
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions read-cache.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,14 +840,14 @@ int discard_cache()
{
int ret;

active_nr = active_cache_changed = 0;
index_file_timestamp = 0;
cache_tree_free(&active_cache_tree);
if (cache_mmap == NULL)
return 0;
ret = munmap(cache_mmap, cache_mmap_size);
cache_mmap = NULL;
cache_mmap_size = 0;
active_nr = active_cache_changed = 0;
index_file_timestamp = 0;
cache_tree_free(&active_cache_tree);

/* no need to throw away allocated active_cache */
return ret;
Expand Down

0 comments on commit 4147d80

Please sign in to comment.