X-Git-Url: http://git.chise.org/gitweb/?a=blobdiff_plain;f=src%2Fm17n-core.c;h=ec250ca7335e4a9f3a795aeecdd66c5e93c379a7;hb=7ebe3307e5ffe8fa4f5a3151a861ba5ad9625dc7;hp=17931cfa6002bd310de419773e3370b2d19edd4f;hpb=3a00e8669c5b7a126dc2b297ce75c9d457cb291c;p=m17n%2Fm17n-lib.git diff --git a/src/m17n-core.c b/src/m17n-core.c index 17931cf..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) @@ -496,10 +506,10 @@ m17n_init_core (void) { int mdebug_mask = MDEBUG_INIT; + merror_code = MERROR_NONE; if (m17n__core_initialized++) return; - merror_code = MERROR_NONE; m17n_memory_full_handler = default_error_handler; mdebug__flag = 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 (); } /*** @} */ @@ -714,6 +726,8 @@ m17n_object (int size, void (*freer) (void *)) M17NObject *obj = malloc (size); obj->ref_count = 1; + obj->ref_count_extended = 0; + obj->flag = 0; obj->u.freer = freer; return obj; }