From e05860576bfef29ebd18049c142a735227eb55ed Mon Sep 17 00:00:00 2001 From: "Anselm R. Garbe" Date: Mon, 1 May 2006 23:49:05 +0200 Subject: [PATCH] prevent i from getting MAX_INT in update_view_bars --- cmd/wm/bar.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/cmd/wm/bar.c b/cmd/wm/bar.c index badda912..d2d7ecb9 100644 --- a/cmd/wm/bar.c +++ b/cmd/wm/bar.c @@ -200,19 +200,24 @@ bar_of_name(const char *name) return nil; } +static Bar * +next_unused_bar() +{ + unsigned int i; + for(i = 0; (i < bar.size) && bar.data[i]->intern; i++) + if(!view_of_name(bar.data[i]->name)) + return bar.data[i]; + return nil; +} + void update_view_bars() { unsigned int i; Bar *b = nil; - for(i = 0; (i < bar.size) && bar.data[i]->intern; i++) { - b = bar.data[i]; - if(!view_of_name(b->name)) { - destroy_bar(b); - i--; - } - } + while((b = next_unused_bar())) + destroy_bar(b); for(i = 0; i < view.size; i++) { b = create_bar(view.data[i]->name, True); cext_strlcpy(b->data, view.data[i]->name, sizeof(b->data));