From f9f8a352646c206e72d5afd4f4d712456cf5aad4 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Wed, 20 Aug 2025 05:46:55 +0900 Subject: [PATCH] fd-util: use heap only when nwea() does not work Then, we can avoid malloc in most cases. --- src/basic/fd-util.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/basic/fd-util.c b/src/basic/fd-util.c index 281cdfcc038..f1af57a3d0a 100644 --- a/src/basic/fd-util.c +++ b/src/basic/fd-util.c @@ -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); -- 2.47.3