summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
Diffstat (limited to 'firmware')
-rw-r--r--firmware/common/dircache.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/firmware/common/dircache.c b/firmware/common/dircache.c
index 5f3d418645..3d7fbd520d 100644
--- a/firmware/common/dircache.c
+++ b/firmware/common/dircache.c
@@ -824,6 +824,15 @@ static int dircache_do_rebuild(void)
824 return 1; 824 return 1;
825} 825}
826 826
827/*
828 * Free all associated resources, if any */
829static void dircache_free(void)
830{
831 if (dircache_handle > 0)
832 dircache_handle = core_free(dircache_handle);
833 dircache_size = allocated_size = 0;
834}
835
827/** 836/**
828 * Internal thread that controls transparent cache building. 837 * Internal thread that controls transparent cache building.
829 */ 838 */
@@ -846,7 +855,7 @@ static void dircache_thread(void)
846 case DIRCACHE_BUILD: 855 case DIRCACHE_BUILD:
847 thread_enabled = true; 856 thread_enabled = true;
848 if (dircache_do_rebuild() < 0) 857 if (dircache_do_rebuild() < 0)
849 dircache_handle = core_free(dircache_handle); 858 dircache_free();
850 thread_enabled = false; 859 thread_enabled = false;
851 break ; 860 break ;
852 861
@@ -902,8 +911,8 @@ int dircache_build(int last_size)
902 return 2; 911 return 2;
903 } 912 }
904 913
905 if (dircache_handle > 0) 914 /* start by freeing, as we possibly re-allocate */
906 dircache_handle = core_free(dircache_handle); 915 dircache_free();
907 916
908 if (last_size > DIRCACHE_RESERVE && last_size < DIRCACHE_LIMIT ) 917 if (last_size > DIRCACHE_RESERVE && last_size < DIRCACHE_LIMIT )
909 { 918 {
@@ -1130,8 +1139,7 @@ bool dircache_resume(void)
1130void dircache_disable(void) 1139void dircache_disable(void)
1131{ 1140{
1132 dircache_suspend(); 1141 dircache_suspend();
1133 dircache_handle = core_free(dircache_handle); 1142 dircache_free();
1134 dircache_size = allocated_size = 0;
1135} 1143}
1136 1144
1137/** 1145/**