summaryrefslogtreecommitdiffstats
path: root/cmd-rename-session.c
diff options
context:
space:
mode:
authorNicholas Marriott <nicm@openbsd.org>2010-12-21 22:37:59 +0000
committerNicholas Marriott <nicm@openbsd.org>2010-12-21 22:37:59 +0000
commitacf13ce9784111ca1e42ffc8206e752668476859 (patch)
tree49ccd47b2e589a27dab8657d516133205f07f393 /cmd-rename-session.c
parent1b8488ee75458c4561089bf056c0e911de958428 (diff)
Store sessions in an RB tree by name rather than a list, this is tidier
and allows them to easily be shown sorted in various lists (list-sessions/choose-sessions). Keep a session index which is used in a couple of places internally but make it an ever-increasing number rather than filling in gaps with new sessions.
Diffstat (limited to 'cmd-rename-session.c')
-rw-r--r--cmd-rename-session.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/cmd-rename-session.c b/cmd-rename-session.c
index 0b674ce0..bd9e787f 100644
--- a/cmd-rename-session.c
+++ b/cmd-rename-session.c
@@ -53,8 +53,10 @@ cmd_rename_session_exec(struct cmd *self, struct cmd_ctx *ctx)
if ((s = cmd_find_session(ctx, data->target)) == NULL)
return (-1);
+ RB_REMOVE(sessions, &sessions, s);
xfree(s->name);
s->name = xstrdup(data->arg);
+ RB_INSERT(sessions, &sessions, s);
server_status_session(s);