Skip to content

Commit

Permalink
Replace mallinfo with mallinfo2 on supported systems
Browse files Browse the repository at this point in the history
`mallinfo` is deprecated since glibc 2.33 and has been replaced by mallinfo2.
The deprecation causes building the server to fail if glibc version is > 2.33.

Check if mallinfo2 exist on the system and use it instead.
  • Loading branch information
idoqo authored and grooverdan committed Mar 26, 2021
1 parent 36a0526 commit 48141f3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions config.h.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@
#cmakedefine HAVE_DECL_MADVISE 1
#cmakedefine HAVE_DECL_MHA_MAPSIZE_VA 1
#cmakedefine HAVE_MALLINFO 1
#cmakedefine HAVE_MALLINFO2 1
#cmakedefine HAVE_MEMCPY 1
#cmakedefine HAVE_MEMMOVE 1
#cmakedefine HAVE_MKSTEMP 1
Expand Down
1 change: 1 addition & 0 deletions configure.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ CHECK_FUNCTION_EXISTS (localtime_r HAVE_LOCALTIME_R)
CHECK_FUNCTION_EXISTS (lstat HAVE_LSTAT)
CHECK_FUNCTION_EXISTS (madvise HAVE_MADVISE)
CHECK_FUNCTION_EXISTS (mallinfo HAVE_MALLINFO)
CHECK_FUNCTION_EXISTS (mallinfo2 HAVE_MALLINFO2)
CHECK_FUNCTION_EXISTS (memcpy HAVE_MEMCPY)
CHECK_FUNCTION_EXISTS (memmove HAVE_MEMMOVE)
CHECK_FUNCTION_EXISTS (mkstemp HAVE_MKSTEMP)
Expand Down
8 changes: 6 additions & 2 deletions sql/sql_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -616,8 +616,12 @@ Next alarm time: %lu\n",
(ulong)alarm_info.next_alarm_time);
#endif
display_table_locks();
#ifdef HAVE_MALLINFO
struct mallinfo info= mallinfo();
#if defined(HAVE_MALLINFO2)
struct mallinfo2 info = mallinfo2();
#elif defined(HAVE_MALLINFO)
struct mallinfo info= mallinfo();
#endif
#if defined(HAVE_MALLINFO) || defined(HAVE_MALLINFO2)
char llbuff[10][22];
printf("\nMemory status:\n\
Non-mmapped space allocated from system: %s\n\
Expand Down

0 comments on commit 48141f3

Please sign in to comment.