diff options
author | Harald Welte <laforge@gnumonks.org> | 2016-04-20 10:41:27 +0200 |
---|---|---|
committer | Harald Welte <laforge@gnumonks.org> | 2016-05-05 18:49:22 +0200 |
commit | 69e6c3c7cdaeabbe31f66fffe9606cb6ee2ec8ee (patch) | |
tree | fcd391571c6ba74faba4df043bd1cf8e6413b679 | |
parent | cd9cb90f452ed83a3df0bf9d136aea19186c7f7b (diff) |
Add log_fini() function to release all memory allocated by logging framework
This is e.g. quite useful to call at the end of test code, in order to
show that all memory allocated actually is released before exit().
-rw-r--r-- | include/osmocom/core/logging.h | 1 | ||||
-rw-r--r-- | src/logging.c | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/include/osmocom/core/logging.h b/include/osmocom/core/logging.h index e51487b5..31934111 100644 --- a/include/osmocom/core/logging.h +++ b/include/osmocom/core/logging.h @@ -214,6 +214,7 @@ void logp2(int subsys, unsigned int level, const char *file, int line, int cont, const char *format, ...) __attribute__ ((format (printf, 6, 7))); int log_init(const struct log_info *inf, void *talloc_ctx); +void log_fini(void); int log_check_level(int subsys, unsigned int level); /* context management */ diff --git a/src/logging.c b/src/logging.c index b96e64a1..4d6fd40d 100644 --- a/src/logging.c +++ b/src/logging.c @@ -880,6 +880,21 @@ int log_init(const struct log_info *inf, void *ctx) return 0; } +/* \brief De-initialize the Osmocom logging core + * This function destroys all targets and releases associated memory */ +void log_fini(void) +{ + struct log_target *tar, *tar2; + + llist_for_each_entry_safe(tar, tar2, &osmo_log_target_list, entry) + log_target_destroy(tar); + + talloc_free(osmo_log_info); + osmo_log_info = NULL; + talloc_free(tall_log_ctx); + tall_log_ctx = NULL; +} + /*! \brief Check whether a log entry will be generated. * \returns != 0 if a log entry might get generated by at least one target */ int log_check_level(int subsys, unsigned int level) |