fix mem leak in bidi
This commit is contained in:
@@ -336,6 +336,8 @@ void lv_draw_label(const lv_area_t * coords, const lv_area_t * mask, lv_draw_lab
|
||||
|
||||
if(pos.y > mask->y2) return;
|
||||
}
|
||||
|
||||
lv_mem_test();
|
||||
}
|
||||
|
||||
/**********************
|
||||
|
||||
@@ -72,6 +72,8 @@ void lv_draw_rect(const lv_area_t * coords, const lv_area_t * clip, lv_draw_rect
|
||||
draw_bg(coords, clip, dsc);
|
||||
draw_img(coords, clip, dsc);
|
||||
draw_border(coords, clip, dsc);
|
||||
|
||||
lv_mem_test();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -187,13 +187,15 @@ bool lv_bidi_letter_is_neutral(uint32_t letter)
|
||||
*/
|
||||
uint16_t lv_bidi_get_logical_pos(const char * str_in, char **bidi_txt, uint32_t len, lv_bidi_dir_t base_dir, uint32_t visual_pos, bool *is_rtl)
|
||||
{
|
||||
|
||||
uint32_t pos_conv_len = get_txt_len(str_in, len);
|
||||
char * buf = lv_mem_buf_get(len + 1);
|
||||
if(buf == NULL) return (uint16_t) -1;
|
||||
|
||||
uint16_t *pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t));
|
||||
if(pos_conv_buf == NULL) return (uint16_t) -1;
|
||||
if(pos_conv_buf == NULL) {
|
||||
lv_mem_buf_release(buf);
|
||||
return (uint16_t) -1;
|
||||
}
|
||||
|
||||
if (bidi_txt) *bidi_txt = buf;
|
||||
|
||||
@@ -226,7 +228,10 @@ uint16_t lv_bidi_get_visual_pos(const char * str_in, char **bidi_txt, uint16_t l
|
||||
if(buf == NULL) return (uint16_t) -1;
|
||||
|
||||
uint16_t *pos_conv_buf = lv_mem_buf_get(pos_conv_len * sizeof(uint16_t));
|
||||
if(pos_conv_buf == NULL) return (uint16_t) -1;
|
||||
if(pos_conv_buf == NULL) {
|
||||
lv_mem_buf_release(buf);
|
||||
return (uint16_t) -1;
|
||||
}
|
||||
|
||||
if (bidi_txt) *bidi_txt = buf;
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ lv_res_t lv_mem_test(void)
|
||||
lv_mem_ent_t * e;
|
||||
e = ent_get_next(NULL);
|
||||
while(e) {
|
||||
if(e->header.s.d_size > 200000) {
|
||||
if(e->header.s.d_size > 20000) {
|
||||
printf("mem err\n");
|
||||
while(1);
|
||||
return LV_RES_INV;
|
||||
@@ -435,6 +435,8 @@ uint32_t lv_mem_get_size(const void * data)
|
||||
*/
|
||||
void * lv_mem_buf_get(uint32_t size)
|
||||
{
|
||||
if(size == 0) return NULL;
|
||||
|
||||
/*Try to find a free buffer with suitable size */
|
||||
uint8_t i;
|
||||
for(i = 0; i < LV_MEM_BUF_MAX_NUM; i++) {
|
||||
|
||||
@@ -709,7 +709,7 @@ uint16_t lv_label_get_letter_on(const lv_obj_t * label, lv_point_t * pos)
|
||||
#if LV_USE_BIDI
|
||||
bidi_txt = lv_mem_buf_get(new_line_start - line_start + 1);
|
||||
uint16_t txt_len = new_line_start - line_start;
|
||||
if(bidi_txt[new_line_start] == '\0') txt_len--;
|
||||
if(bidi_txt[new_line_start] == '\0' && txt_len > 0) txt_len--;
|
||||
lv_bidi_process_paragraph(txt + line_start, bidi_txt, txt_len, lv_obj_get_base_dir(label), NULL, 0);
|
||||
#else
|
||||
bidi_txt = (char*)txt + line_start;
|
||||
|
||||
@@ -218,7 +218,9 @@ void lv_roller_set_selected(lv_obj_t * roller, uint16_t sel_opt, lv_anim_enable_
|
||||
anim = LV_ANIM_OFF;
|
||||
#endif
|
||||
|
||||
if(lv_roller_get_selected(roller) == sel_opt) return;
|
||||
/* Set the value even if it's the same as the current value because
|
||||
* if moving to the next option with an animation which was just deleted in the PRESS signal
|
||||
* nothing will continue the animation. */
|
||||
|
||||
lv_roller_ext_t * ext = lv_obj_get_ext_attr(roller);
|
||||
ext->sel_opt_id = sel_opt < ext->option_cnt ? sel_opt : ext->option_cnt - 1;
|
||||
|
||||
Reference in New Issue
Block a user