From 00977fcc156b322516d50db38f27a8a050820c28 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Sun, 14 Feb 2021 20:32:38 +0100 Subject: [PATCH] grid: add new function, grid_row_reset_extra() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This function resets (free:s) all ‘extra’ data associated with a row. --- grid.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/grid.h b/grid.h index 98b34570..fffeca8a 100644 --- a/grid.h +++ b/grid.h @@ -72,3 +72,18 @@ grid_row_in_view(struct grid *grid, int row_no) xassert(row != NULL); return row; } + +static inline void +grid_row_reset_extra(struct row *row) +{ + if (likely(row->extra == NULL)) + return; + + tll_foreach(row->extra->uri_ranges, it) { + free(it->item.uri); + tll_remove(row->extra->uri_ranges, it); + } + + free(row->extra); + row->extra = NULL; +}