prevent i from getting MAX_INT in update_view_bars

This commit is contained in:
Anselm R. Garbe 2006-05-01 23:49:05 +02:00
parent b816a09ffc
commit e05860576b
1 changed files with 12 additions and 7 deletions

View File

@ -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));