From 57cc214fdb28f3fa4ef4792b95fbc23f02fbba99 Mon Sep 17 00:00:00 2001 From: handa Date: Wed, 17 Aug 2005 11:22:48 +0000 Subject: [PATCH] Include "symbol.h". (report_header_printed): This variable deleted. (object_array_root): New variable. (report_object_array): New function. (mdebug__report_object): This function deleted. (mdebug__add_object_array): New function. (m17n_init_core): Call mchartable_init () before mtext_init (). (m17n_fini_core): Call report_object_array (if necessary) and msymbol__free_atable at the end. --- src/m17n-core.c | 68 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 40 insertions(+), 28 deletions(-) diff --git a/src/m17n-core.c b/src/m17n-core.c index 0761735..ec250ca 100644 --- a/src/m17n-core.c +++ b/src/m17n-core.c @@ -373,6 +373,7 @@ #include "m17n-core.h" #include "m17n-misc.h" #include "internal.h" +#include "symbol.h" static void default_error_handler (enum MErrorCode err) @@ -383,7 +384,29 @@ default_error_handler (enum MErrorCode err) static struct timeval time_stack[16]; static int time_stack_index; -static int report_header_printed; +static M17NObjectArray *object_array_root; + +static void +report_object_array () +{ + fprintf (stderr, "%16s %7s %7s %7s\n", + "object", "created", "freed", "alive"); + fprintf (stderr, "%16s %7s %7s %7s\n", + "------", "-------", "-----", "-----"); + for (; object_array_root; object_array_root = object_array_root->next) + { + M17NObjectArray *array = object_array_root; + + fprintf (stderr, "%16s %7d %7d %7d\n", array->name, + array->used, array->used - array->count, array->count); + if (array->used > 0) + { + free (array->objects); + array->count = array->used = 0; + } + } +} + /* Internal API */ @@ -392,29 +415,6 @@ int m17n__core_initialized; int m17n__shell_initialized; int m17n__gui_initialized; -void -mdebug__report_object (char *name, M17NObjectArray *array) -{ - if (! (mdebug__flag & MDEBUG_FINI)) - return; - if (! report_header_printed) - { - fprintf (stderr, "%16s %7s %7s %7s\n", - "object", "created", "freed", "alive"); - fprintf (stderr, "%16s %7s %7s %7s\n", - "------", "-------", "-----", "-----"); - report_header_printed = 1; - } - fprintf (stderr, "%16s %7d %7d %7d\n", name, - array->used, array->used - array->count, array->count); - if (array->used > 0) - { - free (array->objects); - array->count = array->used = 0; - } -} - - void *(*mdatabase__finder) (MSymbol tag1, MSymbol tag2, MSymbol tag3, MSymbol tag4); void *(*mdatabase__loader) (void *); @@ -459,6 +459,16 @@ mdebug__print_time () void +mdebug__add_object_array (M17NObjectArray *array, char *name) +{ + array->name = name; + array->count = 0; + array->next = object_array_root; + object_array_root = array; +} + + +void mdebug__register_object (M17NObjectArray *array, void *object) { if (array->used == 0) @@ -521,14 +531,14 @@ m17n_init_core (void) if (mplist__init () < 0) goto err; MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize plist module.")); + if (mchartable__init () < 0) + goto err; + MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize chartable module.")); if (mtext__init () < 0) goto err; if (mtext__prop_init () < 0) goto err; MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize mtext module.")); - if (mchartable__init () < 0) - goto err; - MDEBUG_PRINT_TIME ("INIT", (stderr, " to initialize chartable module.")); mdatabase__finder = NULL; mdatabase__loader = NULL; @@ -563,7 +573,9 @@ m17n_fini_core (void) MDEBUG_POP_TIME (); MDEBUG_PRINT_TIME ("FINI", (stderr, " to finalize the core modules.")); MDEBUG_POP_TIME (); - report_header_printed = 0; + if (mdebug__flag & MDEBUG_FINI) + report_object_array (); + msymbol__free_table (); } /*** @} */ -- 1.7.10.4