Commit 38fc4569 authored by Kurt Hindenburg's avatar Kurt Hindenburg
Browse files

Add malloc.h check; fixes build on macos

Tested on kubuntu and freebsd
parent 7e42fcc2
Pipeline #99472 passed with stage
in 1 minute and 53 seconds
......@@ -39,6 +39,7 @@ include(ECMQtDeclareLoggingCategory)
include(KDEClangFormat)
# Remove OPTIONAL when we require EMC >= 5.79
include(KDEGitCommitHooks OPTIONAL)
include(CheckIncludeFiles)
# Allows passing e.g. -DECM_ENABLE_SANITIZERS='address;undefined' to cmake.
include(ECMEnableSanitizers)
......@@ -93,6 +94,8 @@ 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)
# See above includes for defaults
add_definitions(
-DQT_NO_FOREACH
......
......@@ -8,6 +8,8 @@
// Own
#include "Screen.h"
#include "config-konsole.h"
// Qt
#include <QTextStream>
......@@ -27,11 +29,13 @@
#include "profile/Profile.h"
#include "profile/ProfileManager.h"
// For malloc_trim, which is a GNU extension
#ifdef __GNUC__
extern "C" {
#include <malloc.h>
}
#ifdef HAVE_MALLOC_H
// For malloc_trim, which is a GNU extension
#ifdef __GNUC__
extern "C" {
#include <malloc.h>
#endif
}
#endif
using namespace Konsole;
......@@ -1703,12 +1707,14 @@ void Screen::setScroll(const HistoryType &t, bool copyPreviousScroll)
t.scroll(_history);
}
#ifdef HAVE_MALLOC_H
#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
......
......@@ -11,3 +11,6 @@
#cmakedefine USE_TERMINALINTERFACEV2
#cmakedefine HAVE_GETPWUID ${HAVE_GETPWUID}
/* Define to 1 if you have the <malloc.h> header file. */
#cmakedefine HAVE_MALLOC_H 1
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment