Bug 333874

Summary: Baloo does not compile on non-Linux platforms
Product: [Frameworks and Libraries] Baloo Reporter: Nicolas Pavillon <nicos>
Component: GeneralAssignee: Vishesh Handa <me>
Status: RESOLVED FIXED    
Severity: normal CC: arthur, iandw.au, niederstrasser
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: MacPorts   
OS: macOS   
Latest Commit: Version Fixed In:
Attachments: Suppresses use of malloc_trim on non-GNU/Linux platforms

Description Nicolas Pavillon 2014-04-25 14:12:31 UTC
Baloo employs the function malloc_trim(), which is not available non non-Linux systems, such as Mac OS X. 
It is used at least in ./src/xapian/xapiandatabase.cpp, where conditional code should be used for other platforms.

Reproducible: Always

Steps to Reproduce:
1. Try to compile baloo package
Actual Results:  
Compilation breaks
./baloo-4.13.0/src/xapian/xapiandatabase.cpp:27:10: fatal error: 'malloc.h' file not found
#include <malloc.h>
or, by replacing <malloc.h> with <sys/malloc.h>
:5: error: use of undeclared identifier 'malloc_trim'
    malloc_trim(0);

Expected Results:  
Compilation finishing fine.
Comment 1 Vishesh Handa 2014-04-25 15:04:13 UTC
Provide a patch?
Comment 2 Nicolas Pavillon 2014-04-27 03:28:32 UTC
I am not in a position to provide a patch which is functionally equivalent, as the malloc_trim() function does not have direct analogs on other platforms. The attached patch ensures compilation by suppressing the function on other platforms.
Comment 3 Nicolas Pavillon 2014-04-27 03:29:24 UTC
Created attachment 86288 [details]
Suppresses use of malloc_trim on non-GNU/Linux platforms
Comment 4 Vishesh Handa 2014-05-12 14:42:26 UTC
Git commit a1d2889e3128709eac833ad1660a595c773f4552 by Vishesh Handa.
Committed on 12/05/2014 at 11:25.
Pushed by vhanda into branch 'KDE/4.13'.

XapianDB: We only need the headers for malloc_trim

M  +2    -0    src/xapian/xapiandatabase.cpp

http://commits.kde.org/baloo/a1d2889e3128709eac833ad1660a595c773f4552
Comment 5 Ian Wadham 2014-05-18 03:24:29 UTC
This conflicts with a similar change in the master branch to get around the same problem in FreeBSD.  Refer to https://git.reviewboard.kde.org/r/117187/ and commit ad0c5818 of 15 May.

Vishesh, please could you reconcile these changes?
Comment 6 Hanspeter Niederstrasser 2014-06-09 23:23:37 UTC
In commit a1d2889e3128709eac833ad1660a595c773f4552,
#include <unistd.h> needs to be kept outside the #ifdef.  Otherwise the build fails on OS X 10.9 with use of undeclared identifier 'usleep'.