diff options
-rw-r--r-- | TODO | 4 | ||||
-rw-r--r-- | src/cmdline.c | 4 | ||||
-rw-r--r-- | src/error.c | 5 | ||||
-rw-r--r-- | src/expressions.c | 4 | ||||
-rw-r--r-- | src/help.c | 4 | ||||
-rw-r--r-- | src/memory.c | 4 | ||||
-rw-r--r-- | src/parser.c | 4 | ||||
-rw-r--r-- | src/sciteco.h | 10 | ||||
-rw-r--r-- | src/spawn.c | 4 | ||||
-rwxr-xr-x | src/symbols-extract.tes | 5 |
10 files changed, 19 insertions, 29 deletions
@@ -473,10 +473,6 @@ Optimizations: * Add a configure-switch for LTO (--enable-lto). * undo__teco_interface_ssm() could always include the check for teco_current_doc_must_undo(). - * Define TECO_DESTRUCTOR depending on NDEBUG instead - of ifdefing all __attribute__((destructors)). - This also avoids warning for symbols referenced only in - the constructors. Documentation: * Code docs (Doxygen). It's slowly getting better... diff --git a/src/cmdline.c b/src/cmdline.c index 58d48b4..361940d 100644 --- a/src/cmdline.c +++ b/src/cmdline.c @@ -316,15 +316,13 @@ teco_cmdline_fnmacro(const gchar *name, GError **error) return TRUE; } -#ifndef NDEBUG -static void __attribute__((destructor)) +static void TECO_DEBUG_CLEANUP teco_cmdline_cleanup(void) { teco_machine_main_clear(&teco_cmdline.machine); teco_string_clear(&teco_cmdline.str); teco_string_clear(&teco_last_cmdline); } -#endif /* * Commandline key processing. diff --git a/src/error.c b/src/error.c index 7c4e151..45428df 100644 --- a/src/error.c +++ b/src/error.c @@ -161,10 +161,7 @@ teco_error_add_frame_toplevel(void) teco_error_add_frame(TECO_FRAME_TOPLEVEL, 0); } -#ifndef NDEBUG -__attribute__((destructor)) -#endif -void +void TECO_DEBUG_CLEANUP teco_error_clear_frames(void) { teco_stailq_entry_t *entry; diff --git a/src/expressions.c b/src/expressions.c index 57e2f71..1f5740f 100644 --- a/src/expressions.c +++ b/src/expressions.c @@ -374,11 +374,9 @@ teco_expressions_format(gchar *buffer, teco_int_t number) return p; } -#ifndef NDEBUG -static void __attribute__((destructor)) +static void TECO_DEBUG_CLEANUP teco_expressions_cleanup(void) { g_array_free(teco_numbers, TRUE); g_array_free(teco_operators, TRUE); } -#endif @@ -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 diff --git a/src/memory.c b/src/memory.c index 6d7645c..d26b794 100644 --- a/src/memory.c +++ b/src/memory.c @@ -628,8 +628,7 @@ teco_memory_stop_limiting(void) g_mutex_unlock(&teco_memory_mutex); } -#ifndef NDEBUG -static void __attribute__((destructor)) +static void TECO_DEBUG_CLEANUP teco_memory_cleanup(void) { if (!teco_memory_thread) @@ -642,7 +641,6 @@ teco_memory_cleanup(void) g_thread_join(teco_memory_thread); } -#endif #else /* !NEED_POLL_THREAD */ diff --git a/src/parser.c b/src/parser.c index 910fc7f..7bc683e 100644 --- a/src/parser.c +++ b/src/parser.c @@ -52,13 +52,11 @@ teco_loop_stack_init(void) TECO_DEFINE_ARRAY_UNDO_INSERT_VAL(teco_loop_stack, teco_loop_context_t); TECO_DEFINE_ARRAY_UNDO_REMOVE_INDEX(teco_loop_stack); -#ifndef NDEBUG -static void __attribute__((destructor)) +static void TECO_DEBUG_CLEANUP teco_loop_stack_cleanup(void) { g_array_free(teco_loop_stack, TRUE); } -#endif gboolean teco_machine_input(teco_machine_t *ctx, gchar chr, GError **error) diff --git a/src/sciteco.h b/src/sciteco.h index 87bd973..5734c57 100644 --- a/src/sciteco.h +++ b/src/sciteco.h @@ -58,6 +58,16 @@ teco_is_failure(teco_bool_t x) return x >= 0; } +/** + * Call function as destructor on debug builds. + * This should be used only if the cleanup is optional. + */ +#ifdef NDEBUG +#define TECO_DEBUG_CLEANUP __attribute__((unused)) +#else +#define TECO_DEBUG_CLEANUP __attribute__((destructor)) +#endif + /** TRUE if C is a control character */ #define TECO_IS_CTL(C) ((C) < ' ') /** ASCII character to echo control character C */ diff --git a/src/spawn.c b/src/spawn.c index a30e6b2..7515fd6 100644 --- a/src/spawn.c +++ b/src/spawn.c @@ -789,8 +789,7 @@ teco_spawn_idle_cb(gpointer user_data) return G_SOURCE_CONTINUE; } -#ifndef NDEBUG -static void __attribute__((destructor)) +static void TECO_DEBUG_CLEANUP teco_spawn_cleanup(void) { g_source_unref(teco_spawn_ctx.idle_src); @@ -801,4 +800,3 @@ teco_spawn_cleanup(void) if (teco_spawn_ctx.error) g_error_free(teco_spawn_ctx.error); } -#endif diff --git a/src/symbols-extract.tes b/src/symbols-extract.tes index 9f43fa6..9b55e93 100755 --- a/src/symbols-extract.tes +++ b/src/symbols-extract.tes @@ -48,13 +48,12 @@ teco_symbols_init(void) teco_symbol_list_init(&Q[getopt.n], entries, G_N_ELEMENTS(entries), FALSE); } -#ifndef NDEBUG -static void __attribute__((destructor)) +static void TECO_DEBUG_CLEANUP teco_cmdline_cleanup(void) { teco_symbol_list_clear(&Q[getopt.n]); } -#endif^J + !* write output file *! 2EL EWQ#ou |