From: Yu Watanabe Date: Tue, 19 Aug 2025 20:46:55 +0000 (+0900) Subject: fd-util: use heap only when nwea() does not work X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F38878%2Fhead;p=thirdparty%2Fsystemd.git fd-util: use heap only when nwea() does not work Then, we can avoid malloc in most cases. --- 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);