diff --git a/src/fsm/log/manager.c b/src/fsm/log/manager.c index e6f733d..d865bc4 100644 --- a/src/fsm/log/manager.c +++ b/src/fsm/log/manager.c @@ -47,7 +47,7 @@ * * Limiting the access to gg_logs helps to avoid uncontrolled operations on it. */ -static fsm_log_struct gg_logs; +static fsm_log_struct gg_logs = { 0 }; /** diff --git a/src/fsm/log/oper.c b/src/fsm/log/oper.c index 047c465..288eeba 100644 --- a/src/fsm/log/oper.c +++ b/src/fsm/log/oper.c @@ -45,7 +45,7 @@ static int string_1_size = 40; static int string_2_size = 40; -static int string_3_size = 40; +static int string_3_size = 50; /** * Inits the log: a double chained list. @@ -128,6 +128,11 @@ void fsm_add_log_event (fsm_log_struct *jj, else jj->last = new_unit; jj->first = new_unit; + + free (new_unit->file_source); + free (new_unit->function_source); + free (new_unit->string_value); +// free (new_unit); } @@ -146,11 +151,12 @@ void fsm_add_log_event (fsm_log_struct *jj, void fsm_publish_log (fsm_log_struct jj) { fsm_log_unit_struct *a_unit = jj.last; - char buf [LOG_MAX_LENGTH]; + char buf [LOG_MAX_LENGTH] = { 0 }; int nb = 0; while (a_unit) { strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm)); +/* g_message ("%s + %-6ld %6d %-28s %-32s %-40s", buf, a_unit->usec, @@ -158,10 +164,24 @@ void fsm_publish_log (fsm_log_struct jj) a_unit->file_source, a_unit->function_source, a_unit->string_value); - free (a_unit->string_value); +*/ + printf ("%d\n", nb); a_unit = a_unit->prev; nb ++; } } +/* + * LEAK SUMMARY: + * + * g_message (+) or printf + * definitely lost: 5,008 bytes in 54 blocks + * indirectly lost: 16,151 bytes in 673 blocks + * + * g_message (-) + * definitely lost: 5,776 bytes in 55 blocks + * indirectly lost: 17,703 bytes in 728 blocks +*/ + + diff --git a/src/main.c b/src/main.c index 93aca3a..13a9246 100644 --- a/src/main.c +++ b/src/main.c @@ -63,15 +63,16 @@ int main (int argc, char **argv) GtkApplication *app; int status; - fsm_init ("first instruction / first log"); - - fsm_add_log (INFO, MAIN, "main", "*app = gtk_application_new()", - "| 👉️ trigger app initialization"); app = gtk_application_new ("org.gem-graph", G_APPLICATION_DEFAULT_FLAGS); + fsm_init ("first instruction / first log"); + fsm_add_log (INFO, MAIN, "main", - "g signal connect (activate)", - "| 👉️ windows creation requested"); + "*app = gtk_application_new()", + "| 👉️ trigger app initialization"); + fsm_add_log (INFO, MAIN, "main", + "g signal connect (activate)", + "| 👉️ windows creation requested"); // g_signal_connect (app, "startup", G_CALLBACK (on_windows_startup), NULL); g_signal_connect (app, "activate", G_CALLBACK (on_app_activation), NULL);