summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorAndrew Potter <agpotter@gmail.com>2021-05-07 15:18:50 -0700
committerSébastien Helleu <flashcode@flashtux.org>2021-05-08 07:25:44 +0200
commitb222e750192d8f3a51228c1ec8a3bf538c383e78 (patch)
tree9cf71198be0d898683474b3be8881ff99d6445a2 /src/core
parentaa7860c9424218d431920bb2cc1692f216878fcb (diff)
downloadweechat-b222e750192d8f3a51228c1ec8a3bf538c383e78.zip
core: Use mallinfo2() when available
mallinfo() is deprecated in glibc 2.33
Diffstat (limited to 'src/core')
-rw-r--r--src/core/wee-debug.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/core/wee-debug.c b/src/core/wee-debug.c
index 71ec34bdd..9a031167e 100644
--- a/src/core/wee-debug.c
+++ b/src/core/wee-debug.c
@@ -24,7 +24,7 @@
#endif
#include <stdlib.h>
-#ifdef HAVE_MALLINFO
+#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
#include <malloc.h>
#endif
#include <string.h>
@@ -255,6 +255,24 @@ debug_windows_tree ()
void
debug_memory ()
{
+#ifdef HAVE_MALLINFO2
+ struct mallinfo2 info;
+
+ info = mallinfo2 ();
+
+ gui_chat_printf (NULL, "");
+ gui_chat_printf (NULL, _("Memory usage (see \"man mallinfo\" for help):"));
+ gui_chat_printf (NULL, " arena :%10zu", info.arena);
+ gui_chat_printf (NULL, " ordblks :%10zu", info.ordblks);
+ gui_chat_printf (NULL, " smblks :%10zu", info.smblks);
+ gui_chat_printf (NULL, " hblks :%10zu", info.hblks);
+ gui_chat_printf (NULL, " hblkhd :%10zu", info.hblkhd);
+ gui_chat_printf (NULL, " usmblks :%10zu", info.usmblks);
+ gui_chat_printf (NULL, " fsmblks :%10zu", info.fsmblks);
+ gui_chat_printf (NULL, " uordblks:%10zu", info.uordblks);
+ gui_chat_printf (NULL, " fordblks:%10zu", info.fordblks);
+ gui_chat_printf (NULL, " keepcost:%10zu", info.keepcost);
+#else
#ifdef HAVE_MALLINFO
struct mallinfo info;
@@ -277,6 +295,7 @@ debug_memory ()
_("Memory usage not available (function \"mallinfo\" not "
"found)"));
#endif /* HAVE_MALLINFO */
+#endif /* HAVE_MALLINFO2 */
}
/*