mirror of
https://github.com/KDE/konsole.git
synced 2025-12-23 23:38:08 -05:00
Detect the presence of malloc_trim to fix the build with musl
malloc_trim is indeed a GNU extension, but an extension of glibc. Relying on __GNUC__ unfortunately doesn't help with that. Check for the actual presence of malloc_trim with cmake's check_function_exists instead. This fixes the build with musl libc, which doesn't come with malloc_trim. Co-authored-by: Ahmad Samir <a.samirh78@gmail.com>
This commit is contained in:
@@ -94,7 +94,7 @@ set(HAVE_X11 ${X11_FOUND})
|
||||
# Check for function GETPWUID
|
||||
check_symbol_exists(getpwuid "pwd.h" HAVE_GETPWUID)
|
||||
|
||||
check_include_files(malloc.h HAVE_MALLOC_H)
|
||||
check_function_exists(malloc_trim HAVE_MALLOC_TRIM)
|
||||
|
||||
# See above includes for defaults
|
||||
add_definitions(
|
||||
|
||||
@@ -28,13 +28,11 @@
|
||||
#include "history/HistoryType.h"
|
||||
#include "profile/Profile.h"
|
||||
|
||||
#ifdef HAVE_MALLOC_H
|
||||
// For malloc_trim, which is a GNU extension
|
||||
#ifdef __GNUC__
|
||||
extern "C" {
|
||||
#include <malloc.h>
|
||||
}
|
||||
#endif
|
||||
#ifdef HAVE_MALLOC_TRIM
|
||||
// For malloc_trim, which is a GNU extension
|
||||
extern "C" {
|
||||
#include <malloc.h>
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace Konsole;
|
||||
@@ -1799,14 +1797,13 @@ void Screen::setScroll(const HistoryType &t, bool copyPreviousScroll)
|
||||
t.scroll(_history);
|
||||
}
|
||||
_graphicsPlacements.clear();
|
||||
#ifdef HAVE_MALLOC_H
|
||||
#ifdef HAVE_MALLOC_TRIM
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#ifdef __GNUC__
|
||||
// We might have been using gigabytes of memory, so make sure it is actually released
|
||||
malloc_trim(0);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Screen::hasScroll() const
|
||||
|
||||
@@ -15,5 +15,5 @@
|
||||
|
||||
#cmakedefine HAVE_GETPWUID ${HAVE_GETPWUID}
|
||||
|
||||
/* Define to 1 if you have the <malloc.h> header file. */
|
||||
#cmakedefine HAVE_MALLOC_H 1
|
||||
/* Defined if system has the malloc_trim function, which is a GNU extension */
|
||||
#cmakedefine HAVE_MALLOC_TRIM
|
||||
|
||||
Reference in New Issue
Block a user