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:
Todd C. Miller
2009-09-03 13:21:43 +00:00
parent 2935e2a5ba
commit 568c99b099

View File

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