Skip to content

capsule-wrappers: Try to avoid using the deprecated mallinfo()

Ludovico de Nittis requested to merge denittis/libcapsule:use_mallinfo2 into master

mallinfo() has been deprecated since glibc 2.33 and has been replaced with mallinfo2().

Building libcapsule with glibc 2.33 fails with the following error:

capsule/capsule-wrappers.c: In function ‘address_within_main_heap’:
capsule/capsule-wrappers.c:323:20: error: ‘mallinfo’ is deprecated
[-Werror=deprecated-declarations]
  323 |             struct mallinfo mi = mallinfo();
      |                    ^~~~~~~~
In file included from capsule/capsule-wrappers.c:16:
/usr/include/malloc.h:118:24: note: declared here
118 | extern struct mallinfo mallinfo (void) __THROW
__MALLOC_DEPRECATED;
      |                        ^~~~~~~~
cc1: all warnings being treated as errors

To fix that we try to use the newer mallinfo2(), if it is available.

/cc @smcv @vivek

Merge request reports