diff options
author | Tiago Cunha <tcunha@gmx.com> | 2009-11-22 00:10:39 +0000 |
---|---|---|
committer | Tiago Cunha <tcunha@gmx.com> | 2009-11-22 00:10:39 +0000 |
commit | 1d58ca61a740b414bed934561450cdf3c95c8355 (patch) | |
tree | 0e6113f6c76b4d64ac23fe5a9403ad73957b5931 | |
parent | 074780fea4334057192fd172c45c66b8802ffd1a (diff) | |
download | rtmux-1d58ca61a740b414bed934561450cdf3c95c8355.tar.gz rtmux-1d58ca61a740b414bed934561450cdf3c95c8355.tar.bz2 rtmux-1d58ca61a740b414bed934561450cdf3c95c8355.zip |
Sync OpenBSD patchset 556:
Remove oldest messages from log when limit is hit, not newest.
-rw-r--r-- | status.c | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -1,4 +1,4 @@ -/* $Id: status.c,v 1.134 2009-11-22 00:09:42 tcunha Exp $ */ +/* $Id: status.c,v 1.135 2009-11-22 00:10:39 tcunha Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net> @@ -650,10 +650,13 @@ status_message_set(struct client *c, const char *fmt, ...) limit = 0; else limit = options_get_number(&s->options, "message-limit"); - for (i = ARRAY_LENGTH(&c->message_log); i > limit; i--) { - msg = &ARRAY_ITEM(&c->message_log, i - 1); - xfree(msg->msg); - ARRAY_REMOVE(&c->message_log, i - 1); + if (ARRAY_LENGTH(&c->message_log) > limit) { + limit = ARRAY_LENGTH(&c->message_log) - limit; + for (i = 0; i < limit; i++) { + msg = &ARRAY_FIRST(&c->message_log); + xfree(msg->msg); + ARRAY_REMOVE(&c->message_log, 0); + } } delay = options_get_number(&c->session->options, "display-time"); |