Commit 49efd38c authored by Robert Schmidt's avatar Robert Schmidt

Implement logTerm() to close logging subsystem

parent 6ef5ad5a
...@@ -411,6 +411,16 @@ int register_log_component(char *name, ...@@ -411,6 +411,16 @@ int register_log_component(char *name,
return computed_compidx; return computed_compidx;
} }
static void unregister_all_log_components(void)
{
log_component_t* lc = &g_log->log_component[0];
while (lc->name) {
free((char *)lc->name); // defined as const, but assigned through strdup()
free(lc->filelog_name);
lc++;
}
}
int isLogInitDone (void) int isLogInitDone (void)
{ {
if (g_log == NULL) if (g_log == NULL)
...@@ -502,6 +512,12 @@ int logInit (void) ...@@ -502,6 +512,12 @@ int logInit (void)
return 0; return 0;
} }
void logTerm(void)
{
unregister_all_log_components();
free_and_zero(g_log);
}
#include <sys/syscall.h> #include <sys/syscall.h>
static inline int log_header(log_component_t *c, static inline int log_header(log_component_t *c,
char *log_buffer, char *log_buffer,
......
...@@ -302,6 +302,7 @@ extern "C" { ...@@ -302,6 +302,7 @@ extern "C" {
# include "log_if.h" # include "log_if.h"
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
int logInit (void); int logInit (void);
void logTerm (void);
int isLogInitDone (void); int isLogInitDone (void);
void logRecord_mt(const char *file, const char *func, int line,int comp, int level, const char *format, ...) __attribute__ ((format (printf, 6, 7))); void logRecord_mt(const char *file, const char *func, int line,int comp, int level, const char *format, ...) __attribute__ ((format (printf, 6, 7)));
void vlogRecord_mt(const char *file, const char *func, int line, int comp, int level, const char *format, va_list args ); void vlogRecord_mt(const char *file, const char *func, int line, int comp, int level, const char *format, va_list args );
......
...@@ -666,6 +666,7 @@ int main(int argc, char **argv) ...@@ -666,6 +666,7 @@ int main(int argc, char **argv)
vcd_signal_dumper_close(); vcd_signal_dumper_close();
loader_reset(); loader_reset();
logTerm();
return (n_errors); return (n_errors);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment