From 437b76812da77a20ffb4d6914491761791bffc0c Mon Sep 17 00:00:00 2001 From: David Maciejak Date: Sat, 11 Feb 2023 06:35:09 +0800 Subject: [PATCH] Info Panel: mallinfo is deprecated use mallinfo2 instead Replacing mallinfo with 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. --- configure.ac | 2 +- src/dialog.c | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/configure.ac b/configure.ac index 1b95ee48..211689d2 100644 --- a/configure.ac +++ b/configure.ac @@ -387,7 +387,7 @@ AC_FUNC_MEMCMP AC_FUNC_VPRINTF WM_FUNC_SECURE_GETENV AC_CHECK_FUNCS(gethostname select poll strcasecmp strncasecmp \ - setsid mallinfo mkstemp sysconf) + setsid mallinfo2 mkstemp sysconf) AC_SEARCH_LIBS([strerror], [cposix]) dnl nanosleep is generally available in standard libc, although not always the diff --git a/src/dialog.c b/src/dialog.c index 4c5d7b37..7f3a0ef4 100755 --- a/src/dialog.c +++ b/src/dialog.c @@ -1320,14 +1320,15 @@ void wShowInfoPanel(WScreen *scr) break; } -#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO) +#if defined(HAVE_MALLOC_H) && defined(HAVE_MALLINFO2) + { - struct mallinfo ma = mallinfo(); + struct mallinfo2 ma = mallinfo2(); snprintf(buffer, sizeof(buffer), #ifdef DEBUG - _("Total memory allocated: %i kB (in use: %i kB, %d free chunks).\n"), + _("Total memory allocated: %lu kB (in use: %lu kB, %lu free chunks).\n"), #else - _("Total memory allocated: %i kB (in use: %i kB).\n"), + _("Total memory allocated: %lu kB (in use: %lu kB).\n"), #endif (ma.arena + ma.hblkhd) / 1024, (ma.uordblks + ma.hblkhd) / 1024 -- 2.11.4.GIT