mallinfo-util: assume mallinfo() exists
The check existed for musl. Let's remove it, as we explicitly request glibc. While removing the check, this also drops generic_mallinfo, introduces a tiny converter from struct mallinfo to struct mallinfo2 if mallinfo2() does not exist, and renames mallinfo-util.h to malloc.h. With this change, we can drop many ifdefs and casts in .c files.
This commit is contained in:
committed by
Lennart Poettering
parent
17f2b40f22
commit
abb99d3168
@@ -1,6 +1,7 @@
|
||||
/* SPDX-License-Identifier: LGPL-2.1-or-later */
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <malloc.h>
|
||||
#include <string.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -20,7 +21,6 @@
|
||||
#include "label.h"
|
||||
#include "label-util.h"
|
||||
#include "log.h"
|
||||
#include "mallinfo-util.h"
|
||||
#include "path-util.h"
|
||||
#include "selinux-util.h"
|
||||
#include "string-util.h"
|
||||
@@ -106,14 +106,10 @@ static int open_label_db(void) {
|
||||
struct selabel_handle *hnd;
|
||||
/* Avoid maybe-uninitialized false positives */
|
||||
usec_t before_timestamp = USEC_INFINITY, after_timestamp = USEC_INFINITY;
|
||||
# if HAVE_GENERIC_MALLINFO
|
||||
generic_mallinfo before_mallinfo = {};
|
||||
# endif
|
||||
struct mallinfo2 before_mallinfo = {};
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
# if HAVE_GENERIC_MALLINFO
|
||||
before_mallinfo = generic_mallinfo_get();
|
||||
# endif
|
||||
before_mallinfo = mallinfo2();
|
||||
before_timestamp = now(CLOCK_MONOTONIC);
|
||||
}
|
||||
|
||||
@@ -123,16 +119,11 @@ static int open_label_db(void) {
|
||||
|
||||
if (DEBUG_LOGGING) {
|
||||
after_timestamp = now(CLOCK_MONOTONIC);
|
||||
# if HAVE_GENERIC_MALLINFO
|
||||
generic_mallinfo after_mallinfo = generic_mallinfo_get();
|
||||
size_t l = LESS_BY((size_t) after_mallinfo.uordblks, (size_t) before_mallinfo.uordblks);
|
||||
struct mallinfo2 after_mallinfo = mallinfo2();
|
||||
size_t l = LESS_BY(after_mallinfo.uordblks, before_mallinfo.uordblks);
|
||||
log_debug("Successfully loaded SELinux database in %s, size on heap is %zuK.",
|
||||
FORMAT_TIMESPAN(after_timestamp - before_timestamp, 0),
|
||||
DIV_ROUND_UP(l, 1024));
|
||||
# else
|
||||
log_debug("Successfully loaded SELinux database in %s.",
|
||||
FORMAT_TIMESPAN(after_timestamp - before_timestamp, 0));
|
||||
# endif
|
||||
}
|
||||
|
||||
/* release memory after measurement */
|
||||
|
||||
Reference in New Issue
Block a user