Skip to main content
14-Alexandrite
Feb 14, 2024 6:03 PM UTC
Solved

Remove row from C SDK edge infotable

Hello,

 

Is there a method to delete a row from infotable 'twInfoTable' on C SDK.

I am able to add row twInfoTable_AddRow, also update specific entry in row using 'twList_ReplaceValue'

But couldn't delete a row.

I tried this example after add 3 rows in my example datatable  (the second row exist 😞

twInfoTable* it = TW_GET_PROPERTY(DEFAULT_THING_NAME, "Inventory").infotable;
twInfoTableRow* it_row = twInfoTable_GetEntry(it, 1);
twInfoTableRow_Delete(it_row);
TW_SET_PROPERTY(DEFAULT_THING_NAME, "Inventory", twPrimitive_CreateFromInfoTable(it));

 I have a classic c error :Segmentation fault (core dumped) at the last line of code.

Thank you for your help.

14-Alexandrite
Apr 19, 2024 1:30 PM UTC

I find out the solution and it's very simple

we can use twList_Remove(..) to remove a row from an infotable

After all infotable its a list of rows so we can use directly twList_Remove(infotable->rows, rowToDelete, TRUE)

 

4 replies

Rocko
19-Tanzanite
Feb 15, 2024 8:02 AM UTC

My C days are long gone, but you haven't checked it_row for null, are you sure it's not null?

Translate
14-Alexandrite
Feb 15, 2024 8:10 AM UTC

Already checked 

Translate
Rocko
19-Tanzanite
Feb 15, 2024 8:23 AM UTC

I am by no way an expert on this, but I recommend creating a ticket with Support. To me it looks like twInfoTableRow_Delete just frees the memory but does not remove the row from the infotable. The workaround would be to copy over the rows you want to keep to a new infotable.

Translate