fd-util: use heap only when nwea() does not work

Then, we can avoid malloc in most cases.
This commit is contained in:
Yu Watanabe
2025-09-10 19:20:50 +09:00
parent 93d037dbd0
commit f9f8a35264
+1 -1
View File
@@ -410,7 +410,7 @@ int close_all_fds(const int except[], size_t n_except) {
assert(n_except < SIZE_MAX);
n_sorted = n_except + 1;
if (n_sorted > 64) /* Use heap for large numbers of fds, stack otherwise */
if (n_sorted > ALLOCA_MAX / sizeof(int)) /* Use heap for large numbers of fds, stack otherwise */
sorted = sorted_malloc = new(int, n_sorted);
else
sorted = newa(int, n_sorted);