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; 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 void
update_view_bars() update_view_bars()
{ {
unsigned int i; unsigned int i;
Bar *b = nil; Bar *b = nil;
for(i = 0; (i < bar.size) && bar.data[i]->intern; i++) { while((b = next_unused_bar()))
b = bar.data[i]; destroy_bar(b);
if(!view_of_name(b->name)) {
destroy_bar(b);
i--;
}
}
for(i = 0; i < view.size; i++) { for(i = 0; i < view.size; i++) {
b = create_bar(view.data[i]->name, True); b = create_bar(view.data[i]->name, True);
cext_strlcpy(b->data, view.data[i]->name, sizeof(b->data)); cext_strlcpy(b->data, view.data[i]->name, sizeof(b->data));