=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/window.c,v retrieving revision 1.62 retrieving revision 1.63 diff -u -r1.62 -r1.63 --- src/usr.bin/tmux/window.c 2011/01/08 01:52:37 1.62 +++ src/usr.bin/tmux/window.c 2011/01/25 22:31:50 1.63 @@ -1,4 +1,4 @@ -/* $OpenBSD: window.c,v 1.62 2011/01/08 01:52:37 nicm Exp $ */ +/* $OpenBSD: window.c,v 1.63 2011/01/25 22:31:50 nicm Exp $ */ /* * Copyright (c) 2007 Nicholas Marriott @@ -123,7 +123,7 @@ } struct winlink * -winlink_add(struct winlinks *wwl, struct window *w, int idx) +winlink_add(struct winlinks *wwl, int idx) { struct winlink *wl; @@ -135,15 +135,19 @@ wl = xcalloc(1, sizeof *wl); wl->idx = idx; - wl->window = w; RB_INSERT(winlinks, wwl, wl); - w->references++; - return (wl); } void +winlink_set_window(struct winlink *wl, struct window *w) +{ + wl->window = w; + w->references++; +} + +void winlink_remove(struct winlinks *wwl, struct winlink *wl) { struct window *w = wl->window; @@ -153,11 +157,13 @@ xfree(wl->status_text); xfree(wl); - if (w->references == 0) - fatal("bad reference count"); - w->references--; - if (w->references == 0) - window_destroy(w); + if (w != NULL) { + if (w->references == 0) + fatal("bad reference count"); + w->references--; + if (w->references == 0) + window_destroy(w); + } } struct winlink *