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 <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann 2012-02-02 17:41:43 +01:00
parent af3a1f3e50
commit ebef2a016b

View File

@ -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;