version 1.21, 2009/08/13 19:04:00 |
version 1.22, 2009/08/13 20:11:58 |
|
|
} |
} |
|
|
int |
int |
winlink_next_index(struct winlinks *wwl) |
winlink_next_index(struct winlinks *wwl, int idx) |
{ |
{ |
u_int i; |
int i; |
|
|
for (i = 0; i < INT_MAX; i++) { |
i = idx; |
|
do { |
if (winlink_find_by_index(wwl, i) == NULL) |
if (winlink_find_by_index(wwl, i) == NULL) |
return (i); |
return (i); |
} |
if (i == INT_MAX) |
|
i = 0; |
fatalx("no free indexes"); |
else |
|
i++; |
|
} while (i != idx); |
|
return (-1); |
} |
} |
|
|
u_int |
u_int |
|
|
{ |
{ |
struct winlink *wl; |
struct winlink *wl; |
|
|
if (idx == -1) |
if (idx < 0) { |
idx = winlink_next_index(wwl); |
if ((idx = winlink_next_index(wwl, -idx - 1)) == -1) |
else if (winlink_find_by_index(wwl, idx) != NULL) |
return (NULL); |
|
} else if (winlink_find_by_index(wwl, idx) != NULL) |
return (NULL); |
return (NULL); |
|
|
if (idx < 0) |
|
fatalx("bad index"); |
|
|
|
wl = xcalloc(1, sizeof *wl); |
wl = xcalloc(1, sizeof *wl); |
wl->idx = idx; |
wl->idx = idx; |