diff options
author | Nicholas Marriott <nicm@openbsd.org> | 2011-08-16 09:36:23 +0000 |
---|---|---|
committer | Nicholas Marriott <nicm@openbsd.org> | 2011-08-16 09:36:23 +0000 |
commit | 6b734d10746ac86a13b05ad48b79e92ca8ccc96b (patch) | |
tree | be8210cbbfd1ceded68695e029d9c986b50057ee /session.c | |
parent | cf90f2a29c4b09585f69d36571555a950e3c1f20 (diff) | |
download | rtmux-6b734d10746ac86a13b05ad48b79e92ca8ccc96b.tar.gz rtmux-6b734d10746ac86a13b05ad48b79e92ca8ccc96b.tar.bz2 rtmux-6b734d10746ac86a13b05ad48b79e92ca8ccc96b.zip |
Correctly skip existing numbers when generating the name for a new
session.
Diffstat (limited to 'session.c')
-rw-r--r-- | session.c | 15 |
1 files changed, 11 insertions, 4 deletions
@@ -119,11 +119,18 @@ session_create(const char *name, const char *cmd, const char *cwd, s->sx = sx; s->sy = sy; - s->idx = next_session++; - if (name != NULL) + if (name != NULL) { s->name = xstrdup(name); - else - xasprintf(&s->name, "%u", s->idx); + s->idx = next_session++; + } else { + s->name = NULL; + do { + s->idx = next_session++; + if (s->name != NULL) + xfree (s->name); + xasprintf(&s->name, "%u", s->idx); + } while (RB_FIND(sessions, &sessions, s) != NULL); + } RB_INSERT(sessions, &sessions, s); if (cmd != NULL) { |