void-packages/srcpkgs/fwupd/patches/musl.patch
2021-03-30 14:02:39 -03:00

44 lines
1.2 KiB
Diff

Upstream: https://github.com/fwupd/fwupd/pull/3080
diff --git a/meson.build b/meson.build
index 86e70573..e870f7b6 100644
--- a/meson.build
+++ b/meson.build
@@ -309,6 +309,12 @@ endif
if cc.has_header('fnmatch.h')
conf.set('HAVE_FNMATCH_H', '1')
endif
+if cc.has_header('malloc.h')
+ conf.set('HAVE_MALLOC_H', '1')
+ if cc.has_function('malloc_trim', prefix: '#include <malloc.h>')
+ conf.set('HAVE_MALLOC_TRIM', '1')
+ endif
+endif
if cc.has_header('cpuid.h') and cc.has_header_symbol('cpuid.h', '__get_cpuid_count') and (host_cpu == 'x86' or host_cpu == 'x86_64')
conf.set('HAVE_CPUID_H', '1')
else
diff --git a/src/fu-main.c b/src/fu-main.c
index b7afde98..5f5de334 100644
--- a/src/fu-main.c
+++ b/src/fu-main.c
@@ -14,7 +14,9 @@
#include <glib/gi18n.h>
#include <glib-unix.h>
#include <locale.h>
+#ifdef HAVE_MALLOC_H
#include <malloc.h>
+#endif
#ifdef HAVE_POLKIT
#include <polkit/polkit.h>
#endif
@@ -2037,8 +2039,10 @@ main (int argc, char *argv[])
else if (timed_exit)
g_timeout_add_seconds (5, fu_main_timed_exit_cb, priv->loop);
+#ifdef HAVE_MALLOC_TRIM
/* drop heap except one page */
malloc_trim (4096);
+#endif
/* wait */
g_message ("Daemon ready for requests (locale %s)", g_getenv ("LANG"));