*data = num;
}
-static void unref_rawdata(struct libscols_table *tb)
+static void unref_line_rawdata(struct libscols_line *ln, struct libscols_table *tb)
+{
+ size_t i;
+
+ for (i = 0; i < ncolumns; i++) {
+ struct libscols_column *cl = scols_table_get_column(tb, i);
+ struct libscols_cell *ce;
+ void *data;
+
+ if (cl != lsblk->sort_col && !scols_column_has_data_func(cl))
+ continue;
+
+ ce = scols_line_get_column_cell(ln, cl);
+ data = scols_cell_get_userdata(ce);
+ free(data);
+ }
+}
+
+static void unref_table_rawdata(struct libscols_table *tb)
{
struct libscols_iter *itr;
struct libscols_line *ln;
itr = scols_new_iter(SCOLS_ITER_FORWARD);
if (!itr)
return;
-
- while (scols_table_next_line(tb, itr, &ln) == 0) {
- size_t i;
-
- for (i = 0; i < ncolumns; i++) {
- struct libscols_column *cl = scols_table_get_column(tb, i);
- struct libscols_cell *ce;
- void *data;
-
- if (cl != lsblk->sort_col && !scols_column_has_data_func(cl))
- continue;
-
- ce = scols_line_get_column_cell(ln, cl);
- data = scols_cell_get_userdata(ce);
- free(data);
- }
- }
+ while (scols_table_next_line(tb, itr, &ln) == 0)
+ unref_line_rawdata(ln, tb);
scols_free_iter(itr);
}
if (x)
scols_line_remove_child(x, ln);
+ unref_line_rawdata(ln, tab);
scols_table_remove_line(tab, ln);
ln = NULL;
}
print_counters();
leave:
if (lsblk->rawdata)
- unref_rawdata(lsblk->table);
+ unref_table_rawdata(lsblk->table);
scols_unref_table(lsblk->table);
scols_unref_filter(lsblk->filter);