Reorg window data structures. Add an intermediate data type (struct winlink) to hold index and make sessions hold a RB tree of them rather than a fixed array.

This commit is contained in:
Nicholas Marriott
2007-10-26 12:29:07 +00:00
parent 9f06104c3a
commit 4ba3cf60be
18 changed files with 347 additions and 349 deletions

View File

@ -1,4 +1,4 @@
/* $Id: cmd-list-sessions.c,v 1.6 2007-10-23 09:36:07 nicm Exp $ */
/* $Id: cmd-list-sessions.c,v 1.7 2007-10-26 12:29:07 nicm Exp $ */
/*
* Copyright (c) 2007 Nicholas Marriott <nicm@users.sourceforge.net>
@ -45,8 +45,9 @@ cmd_list_sessions_exec(unused void *ptr, struct cmd_ctx *ctx)
{
struct client *c = ctx->client;
struct session *s = ctx->session;
struct winlink *wl;
char *tim;
u_int i, j, n;
u_int i, n;
for (i = 0; i < ARRAY_LENGTH(&sessions); i++) {
s = ARRAY_ITEM(&sessions, i);
@ -54,10 +55,8 @@ cmd_list_sessions_exec(unused void *ptr, struct cmd_ctx *ctx)
continue;
n = 0;
for (j = 0; j < ARRAY_LENGTH(&s->windows); j++) {
if (ARRAY_ITEM(&s->windows, j) != NULL)
n++;
}
RB_FOREACH(wl, winlinks, &s->windows)
n++;
tim = ctime(&s->tim);
*strchr(tim, '\n') = '\0';