add lv_mem_assert to memory reallocations
This commit is contained in:
@@ -282,6 +282,7 @@ lv_fs_res_t lv_ufs_write(void * file_p, const void * buf, uint32_t btw, uint32_t
|
||||
uint32_t new_size = fp->rwp + btw;
|
||||
if(new_size > ent->size) {
|
||||
uint8_t * new_data = lv_mem_realloc(ent->data_d, new_size);
|
||||
lv_mem_assert(new_data);
|
||||
if(new_data == NULL) return LV_FS_RES_FULL; /*Cannot allocate the new memory*/
|
||||
|
||||
ent->data_d = new_data;
|
||||
@@ -317,6 +318,7 @@ lv_fs_res_t lv_ufs_seek(void * file_p, uint32_t pos)
|
||||
if(fp->aw == 0) return LV_FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
uint8_t * new_data = lv_mem_realloc(ent->data_d, pos);
|
||||
lv_mem_assert(new_data);
|
||||
if(new_data == NULL) return LV_FS_RES_FULL; /*Out of memory*/
|
||||
|
||||
ent->data_d = new_data;
|
||||
@@ -357,6 +359,7 @@ lv_fs_res_t lv_ufs_trunc(void * file_p)
|
||||
if(fp->aw == 0) return LV_FS_RES_DENIED; /*Not opened for write*/
|
||||
|
||||
void * new_data = lv_mem_realloc(ent->data_d, fp->rwp);
|
||||
lv_mem_assert(new_data);
|
||||
if(new_data == NULL) return LV_FS_RES_FULL; /*Out of memory*/
|
||||
|
||||
ent->data_d = new_data;
|
||||
|
||||
@@ -229,7 +229,8 @@ void lv_chart_set_point_count(lv_obj_t * chart, uint16_t point_cnt)
|
||||
|
||||
LL_READ_BACK(ext->series_ll, ser) {
|
||||
ser->points = lv_mem_realloc(ser->points, sizeof(lv_coord_t) * point_cnt);
|
||||
|
||||
lv_mem_assert(ser->points);
|
||||
if(ser->points == NULL) return;
|
||||
/*Initialize the new points*/
|
||||
if(point_cnt > point_cnt_old) {
|
||||
for(i = point_cnt_old - 1; i < point_cnt; i++) {
|
||||
|
||||
@@ -135,6 +135,8 @@ void lv_gauge_set_needle_count(lv_obj_t * gauge, uint8_t needle_cnt, const lv_co
|
||||
}
|
||||
|
||||
ext->values = lv_mem_realloc(ext->values, needle_cnt * sizeof(int16_t));
|
||||
lv_mem_assert(ext->values);
|
||||
if(ext->values == NULL) return;
|
||||
|
||||
int16_t min = lv_gauge_get_min_value(gauge);
|
||||
uint8_t n;
|
||||
|
||||
@@ -112,6 +112,8 @@ lv_obj_t * lv_label_create(lv_obj_t * par, lv_obj_t * copy)
|
||||
/*In DOT mode save the text byte-to-byte because a '\0' can be in the middle*/
|
||||
if(copy_ext->long_mode == LV_LABEL_LONG_DOT) {
|
||||
ext->text = lv_mem_realloc(ext->text, lv_mem_get_size(copy_ext->text));
|
||||
lv_mem_assert(ext->text);
|
||||
if(ext->text == NULL) return NULL;
|
||||
memcpy(ext->text, copy_ext->text, lv_mem_get_size(copy_ext->text));
|
||||
}
|
||||
|
||||
@@ -148,6 +150,8 @@ void lv_label_set_text(lv_obj_t * label, const char * text)
|
||||
if(ext->text == text) {
|
||||
/*If set its own text then reallocate it (maybe its size changed)*/
|
||||
ext->text = lv_mem_realloc(ext->text, strlen(ext->text) + 1);
|
||||
lv_mem_assert(ext->text);
|
||||
if(ext->text == NULL) return;
|
||||
} else {
|
||||
/*Allocate space for the new text*/
|
||||
uint32_t len = strlen(text) + 1;
|
||||
@@ -591,6 +595,8 @@ void lv_label_ins_text(lv_obj_t * label, uint32_t pos, const char * txt)
|
||||
uint32_t ins_len = strlen(txt);
|
||||
uint32_t new_len = ins_len + old_len;
|
||||
ext->text = lv_mem_realloc(ext->text, new_len + 1);
|
||||
lv_mem_assert(ext->text);
|
||||
if(ext->text == NULL) return;
|
||||
|
||||
if(pos == LV_LABEL_POS_LAST) {
|
||||
#if LV_TXT_UTF8 == 0
|
||||
|
||||
@@ -190,6 +190,7 @@ void lv_ta_add_char(lv_obj_t * ta, char c)
|
||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(ext->pwd_tmp) + 2); /*+2: the new char + \0 */
|
||||
lv_mem_assert(ext->pwd_tmp);
|
||||
if(ext->pwd_tmp== NULL) return;
|
||||
|
||||
lv_txt_ins(ext->pwd_tmp, ext->cursor.pos, letter_buf);
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
@@ -321,6 +322,8 @@ void lv_ta_set_text(lv_obj_t * ta, const char * txt)
|
||||
|
||||
if(ext->pwd_mode != 0) {
|
||||
ext->pwd_tmp = lv_mem_realloc(ext->pwd_tmp, strlen(txt) + 1);
|
||||
lv_mem_assert(ext->pwd_tmp);
|
||||
if(ext->pwd_tmp == NULL) return;
|
||||
strcpy(ext->pwd_tmp, txt);
|
||||
|
||||
#if USE_LV_ANIMATION
|
||||
|
||||
@@ -223,8 +223,12 @@ lv_obj_t * lv_tabview_add_tab(lv_obj_t * tabview, const char * name)
|
||||
name_dm[0] = '\221';
|
||||
strcpy(&name_dm[1], name);
|
||||
}
|
||||
|
||||
ext->tab_cnt++;
|
||||
ext->tab_name_ptr = lv_mem_realloc(ext->tab_name_ptr, sizeof(char *) * (ext->tab_cnt + 1));
|
||||
lv_mem_assert(ext->tab_name_ptr);
|
||||
if(ext->tab_name_ptr == NULL) return NULL;
|
||||
|
||||
ext->tab_name_ptr[ext->tab_cnt - 1] = name_dm;
|
||||
ext->tab_name_ptr[ext->tab_cnt] = "";
|
||||
|
||||
|
||||
Reference in New Issue
Block a user