mallinfo is used as a fallback when the glibc doesn't implement the newer version of it - mallinfo2.
But we doing the lookups for the older mallinfo unconditionally at the initialization phase even though we know it will be unused.
- g_mallinfo = CAST_TO_FN_PTR(mallinfo_func_t, dlsym(RTLD_DEFAULT, "mallinfo"));
g_mallinfo2 = CAST_TO_FN_PTR(mallinfo2_func_t, dlsym(RTLD_DEFAULT, "mallinfo2"));
+ // mallinfo2 was introduced in glibc 2.33
+ if (g_mallinfo2 == nullptr) {
+ g_mallinfo = CAST_TO_FN_PTR(mallinfo_func_t, dlsym(RTLD_DEFAULT, "mallinfo"));
+ }
But we doing the lookups for the older mallinfo unconditionally at the initialization phase even though we know it will be unused.
- g_mallinfo = CAST_TO_FN_PTR(mallinfo_func_t, dlsym(RTLD_DEFAULT, "mallinfo"));
g_mallinfo2 = CAST_TO_FN_PTR(mallinfo2_func_t, dlsym(RTLD_DEFAULT, "mallinfo2"));
+ // mallinfo2 was introduced in glibc 2.33
+ if (g_mallinfo2 == nullptr) {
+ g_mallinfo = CAST_TO_FN_PTR(mallinfo_func_t, dlsym(RTLD_DEFAULT, "mallinfo"));
+ }