From 4ba3cf60beea7be93a1de674226f412e5fec1105 Mon Sep 17 00:00:00 2001 From: Nicholas Marriott Date: Fri, 26 Oct 2007 12:29:07 +0000 Subject: 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. --- cmd-list-sessions.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'cmd-list-sessions.c') diff --git a/cmd-list-sessions.c b/cmd-list-sessions.c index 81aa1bb3..6bacdde2 100644 --- a/cmd-list-sessions.c +++ b/cmd-list-sessions.c @@ -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 @@ -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'; -- cgit