From ebef2a016b55a4fc9270e5862e1c2a65e7ae7b67 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 2 Feb 2012 17:41:43 +0100 Subject: [PATCH] console: allow to push empty lines to scrollback buffer When pushing a line=NULL to the scrollback buffer we now assume that the line was empty and we allocate a new empty line. If the allocation fails we simply drop that line. Signed-off-by: David Herrmann --- src/console_cell.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/console_cell.c b/src/console_cell.c index 2e13cd9..1562542 100644 --- a/src/console_cell.c +++ b/src/console_cell.c @@ -267,8 +267,9 @@ void kmscon_buffer_unref(struct kmscon_buffer *buf) static void link_to_scrollback(struct kmscon_buffer *buf, struct line *line) { struct line *tmp; + int ret; - if (!buf || !line) + if (!buf) return; if (buf->sb_max == 0) { @@ -276,6 +277,14 @@ static void link_to_scrollback(struct kmscon_buffer *buf, struct line *line) return; } + if (!line) { + ret = new_line(&line); + if (ret) { + log_warn("console: cannot allocate line (%d); dropping scrollback-buffer line\n", ret); + return; + } + } + if (buf->sb_count >= buf->sb_max) { tmp = buf->sb_first; buf->sb_first = tmp->next;