Move lambda to static function

This commit is contained in:
topjohnwu 2025-01-19 18:59:17 +08:00
parent c3e8405020
commit a0f13ab49f

View File

@ -216,10 +216,15 @@ DCL_HOOK_FUNC(static int, pthread_attr_destroy, void *target) {
// -----------------------------------------------------------------
static size_t get_fd_max() {
rlimit r{32768, 32768};
getrlimit(RLIMIT_NOFILE, &r);
return r.rlim_max;
}
ZygiskContext::ZygiskContext(JNIEnv *env, void *args) :
env(env), args{args}, process(nullptr), pid(-1), flags(0), info_flags(0),
allowed_fds([] static { rlimit r{32768, 32768}; getrlimit(RLIMIT_NOFILE, &r); return r.rlim_max; }()),
hook_info_lock(PTHREAD_MUTEX_INITIALIZER) { g_ctx = this; }
allowed_fds(get_fd_max()), hook_info_lock(PTHREAD_MUTEX_INITIALIZER) { g_ctx = this; }
ZygiskContext::~ZygiskContext() {
// This global pointer points to a variable on the stack.