I need a widget similar to the existing Table widget, but where I can insert/delete rows dynamically.
So I took a look into lv_table.c to see whether I can extend the table widget to do what I need…
I see that there already exists functionality to add rows and/or columns. But memory management when resizing looks somewhat strange to me.
I understand that ext->cell_data is a pointer to a dynamically allocated array of pointers to the cell contents. This array is resized via lv_mem_realloc() when the table gets resized. That’s fine so far.
But what about the pointers to the cell content, which were allocated in lv_table_set_call_value()? Those pointers will be lost when ext->cell_data is shrunken.
This looks like a memory leak to me. Or am I missing something here?
I agree; it looks like a memory leak. A few months ago I made a dynamically updating table to display something for testing. The app ran out of memory after about 10 minutes. I assumed that I had a leak in my code somewhere and didn’t investigate it further since the table was just for debugging purposes. This is probably the reason for that issue.