1
0
mirror of https://github.com/lvgl/lvgl.git synced 2025-01-14 06:42:58 +08:00

Fix #1400: divide-by-zero error in lv_mem_monitor

This commit is contained in:
embeddedt 2020-03-04 18:10:45 -05:00 committed by GitHub
parent 7f06779179
commit c513977559
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -358,8 +358,12 @@ void lv_mem_monitor(lv_mem_monitor_t * mon_p)
}
mon_p->total_size = LV_MEM_SIZE;
mon_p->used_pct = 100 - (100U * mon_p->free_size) / mon_p->total_size;
if(mon_p->free_size > 0) {
mon_p->frag_pct = (uint32_t)mon_p->free_biggest_size * 100U / mon_p->free_size;
mon_p->frag_pct = 100 - mon_p->frag_pct;
} else {
mon_p->frag_pct = 0; /*no fragmentation if all the RAM is used*/
}
#endif
}