From fd87bca102321e5804fef74dac8a6d267ae46732 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 13 Feb 2021 12:31:55 +0100 Subject: grid: enable rows to have ‘extra’ data associated with them MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch adds an ‘extra’ member to the row struct. It is a pointer to a struct containing extra data to be associated with this row. Initially, this struct contains a list of URL ranges. These define (OSC-8) URLs on this row. The ‘extra’ data is allocated on-demand. I.e. the pointer is NULL by default; it is *not* allocated by grid_row_alloc(). --- grid.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'grid.c') diff --git a/grid.c b/grid.c index 6d6b6b3c..2f0033ec 100644 --- a/grid.c +++ b/grid.c @@ -33,6 +33,7 @@ grid_row_alloc(int cols, bool initialize) struct row *row = xmalloc(sizeof(*row)); row->dirty = false; row->linebreak = false; + row->extra = NULL; if (initialize) { row->cells = xcalloc(cols, sizeof(row->cells[0])); @@ -50,6 +51,14 @@ grid_row_free(struct row *row) if (row == NULL) return; + if (row->extra != NULL) { + tll_foreach(row->extra->uri_ranges, it) { + free(it->item.uri); + tll_remove(row->extra->uri_ranges, it); + } + } + + free(row->extra); free(row->cells); free(row); } -- cgit v1.3