Actually. qsort is fine since most versions fal back to a cheaper
sort when the number of elements to sort is small (like in our case).
This commit is contained in:
3
script.c
3
script.c
@@ -268,11 +268,9 @@ script_duplow(fd)
|
||||
/* sort fds so we can dup them safely */
|
||||
for (i = 0; i < 5; i++)
|
||||
indices[i] = i;
|
||||
/* XXX - qsort is overkill for this */
|
||||
qsort(indices, 5, sizeof(int), fdcompar);
|
||||
|
||||
/* Move pty master/slave and session fds to low numbered fds. */
|
||||
if (def_script) {
|
||||
for (i = 0; i < 5; i++) {
|
||||
j = indices[i];
|
||||
if (script_fds[j] != fd) {
|
||||
@@ -286,7 +284,6 @@ script_duplow(fd)
|
||||
}
|
||||
script_fds[j] = fd++;
|
||||
}
|
||||
}
|
||||
return(fd);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user