From 41a02591b9d199a82bb24c23f3828102375137de Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Mon, 3 Jul 2023 04:27:49 +0300 Subject: introduced TECO_DEBUG_CLEANUP to mark destructors that should only be used for debug builds * There is cleanup that is not strictly necessary, because it only frees memory which is freed on program termination anyway. * However, it helps to explicitly free everything for debugging memory leaks via Valgrind. * The new macro reduces the number of #ifdef statements. * On NDEBUG, the code of these functions will still be eliminated. * If functions are referenced only from the destructor, there will be no unused function warnings, even in NDEBUG. --- src/help.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/help.c') diff --git a/src/help.c b/src/help.c index e06bda4..f69ba6f 100644 --- a/src/help.c +++ b/src/help.c @@ -235,8 +235,7 @@ teco_help_auto_complete(const gchar *topic_name, teco_string_t *insert) topic_name ? strlen(topic_name) : 0, 0, insert); } -#ifndef NDEBUG -static void __attribute__((destructor)) +static void TECO_DEBUG_CLEANUP teco_help_cleanup(void) { if (!teco_help_chunk) @@ -251,7 +250,6 @@ teco_help_cleanup(void) teco_help_topic_free((teco_help_topic_t *)cur); } } -#endif /* * Command states -- cgit v1.2.3