main: Use mallinfo2 when available at build time
`mallinfo` has been deprecated in favor of `mallinfo2`: ``` The fields of the mallinfo structure that is returned by the older mallinfo() function are typed as int. However, because some internal bookkeeping values may be of type long, the reported values may wrap around zero and thus be inaccurate. ``` Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/1786>
This commit is contained in:
10
src/main.c
10
src/main.c
@ -2,7 +2,7 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#ifdef HAVE_MALLINFO
|
||||
#if defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2)
|
||||
#include <malloc.h>
|
||||
#endif
|
||||
#include <stdlib.h>
|
||||
@ -212,8 +212,12 @@ static void
|
||||
malloc_statistics_callback (ShellPerfLog *perf_log,
|
||||
gpointer data)
|
||||
{
|
||||
#ifdef HAVE_MALLINFO
|
||||
#if defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2)
|
||||
#ifdef HAVE_MALLINFO2
|
||||
struct mallinfo2 info = mallinfo2 ();
|
||||
#else
|
||||
struct mallinfo info = mallinfo ();
|
||||
#endif
|
||||
|
||||
shell_perf_log_update_statistic_i (perf_log,
|
||||
"malloc.arenaSize",
|
||||
@ -224,7 +228,7 @@ malloc_statistics_callback (ShellPerfLog *perf_log,
|
||||
shell_perf_log_update_statistic_i (perf_log,
|
||||
"malloc.usedSize",
|
||||
info.uordblks);
|
||||
#endif
|
||||
#endif /* defined (HAVE_MALLINFO) || defined (HAVE_MALLINFO2) */
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user