File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -232,6 +232,8 @@ AC_SUBST(sushell)
232232
233233# selinux-util.c uses struct mallinfo which is not available for all C libraries (musl).
234234AC_CHECK_FUNCS ( [ mallinfo] )
235+ # mallinfo is deprecated, prefer to use mallinfo2 when available
236+ AC_CHECK_FUNCS ( [ mallinfo2] )
235237
236238# ------------------------------------------------------------------------------
237239
Original file line number Diff line number Diff line change @@ -69,7 +69,9 @@ int mac_selinux_init(const char *prefix) {
6969#ifdef HAVE_SELINUX
7070 usec_t before_timestamp , after_timestamp ;
7171
72- #ifdef HAVE_MALLINFO
72+ #ifdef HAVE_MALLINFO2
73+ struct mallinfo2 before_mallinfo , after_mallinfo ;
74+ #elif HAVE_MALLINFO
7375 struct mallinfo before_mallinfo , after_mallinfo ;
7476#endif
7577
@@ -79,7 +81,9 @@ int mac_selinux_init(const char *prefix) {
7981 if (label_hnd )
8082 return 0 ;
8183
82- #ifdef HAVE_MALLINFO
84+ #ifdef HAVE_MALLINFO2
85+ before_mallinfo = mallinfo2 ();
86+ #elif HAVE_MALLINFO
8387 before_mallinfo = mallinfo ();
8488#endif
8589
@@ -100,15 +104,19 @@ int mac_selinux_init(const char *prefix) {
100104 } else {
101105 char timespan [FORMAT_TIMESPAN_MAX ];
102106
103- #ifdef HAVE_MALLINFO
107+ #if defined( HAVE_MALLINFO )|defined( HAVE_MALLINFO2 )
104108 int l ;
105109#endif
106110
107111 after_timestamp = now (CLOCK_MONOTONIC );
108112
109- #ifdef HAVE_MALLINFO
113+ #ifdef HAVE_MALLINFO2
114+ after_mallinfo = mallinfo2 ();
115+ #elif HAVE_MALLINFO
110116 after_mallinfo = mallinfo ();
117+ #endif
111118
119+ #if defined(HAVE_MALLINFO )|defined(HAVE_MALLINFO2 )
112120 l = after_mallinfo .uordblks > before_mallinfo .uordblks ? after_mallinfo .uordblks - before_mallinfo .uordblks : 0 ;
113121
114122 log_debug ("Successfully loaded SELinux database in %s, size on heap is %iK." ,
You can’t perform that action at this time.
0 commit comments