From f695ed58d9cab88470c54bd95b25251e19fcb6d4 Mon Sep 17 00:00:00 2001 From: Nikolas Garofil Date: Fri, 19 Feb 2010 00:09:24 +0100 Subject: [PATCH] Hide false memleaks in a debugbuild This makes sure valgrind doesn't show false memleaks that are caused by ncurses instead of our code when we do a 'Debug' build. There is a also a disadvantage: When your ncurses library is not build with the '--disable-leaks' option (this is the case in the default version of ncurses of most distro's) and you build conky with ncurses and debug turned on then you will see a segmentation fault when you stop conky. On the other hand people that want to build conky as a debug build with ncurses support will probably also have a ncurses with --disable-leaks ... --- src/conky.cc | 6 ++++++ src/nc.h | 11 +++++++++++ 2 files changed, 17 insertions(+) create mode 100644 src/nc.h diff --git a/src/conky.cc b/src/conky.cc index 1627c267..2f6ff6c4 100644 --- a/src/conky.cc +++ b/src/conky.cc @@ -66,6 +66,9 @@ #include #ifdef BUILD_NCURSES #include +#ifdef DEBUG +#include "nc.h" +#endif #endif #ifdef BUILD_WEATHER_XOAP #include @@ -4341,6 +4344,9 @@ int main(int argc, char **argv) kvm_close(kd); #endif +#if defined(BUILD_NCURSES) && defined(DEBUG) + _nc_free_and_exit(0); //hide false memleaks +#endif return 0; } diff --git a/src/nc.h b/src/nc.h new file mode 100644 index 00000000..73dddc9b --- /dev/null +++ b/src/nc.h @@ -0,0 +1,11 @@ +/* -*- mode: c; c-basic-offset: 4; tab-width: 4; indent-tabs-mode: t -*- */ + +#ifdef __cplusplus +extern "C" { +#endif + +void _nc_free_and_exit(int); + +#ifdef __cplusplus +} +#endif