lib

morphux C utility library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/lib

commit 201418b22e601d2d5e3e7b0a820c05a577b8cb47
parent 4a2c06dbae7be46e0b485b9f28663e6a3a45a095
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Mon, 23 Jan 2017 18:44:03 +0100

Fix(Leaks): Fix leaks in tests

Diffstat:
Minc/m_test.h | 1+
Msrc/m_test.c | 13+++++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/inc/m_test.h b/inc/m_test.h @@ -58,5 +58,6 @@ mtest_results_t test_group(char *group); u32_t test_all(void); void test_free(void); int single_test_free(void *ptr); +int single_result_free(void *ptr); #endif /* M_TEST_H */ diff --git a/src/m_test.c b/src/m_test.c @@ -147,6 +147,7 @@ u32_t test_all(void) { m_info("Total:\t\t%d%% (%d/%d)\n", (success * 100) / total, success, total); } list_free(groups, NULL); + list_free(tests_results, &single_result_free); return failed; } @@ -172,3 +173,15 @@ int single_test_free(void *ptr) { } return 1; } + +/*! + * \brief Free a mtest_results_t + * \note Used in test_all, as a list_free callback + */ +int single_result_free(void *ptr) { + mtest_results_t *tmp = ptr; + if (ptr) { + free(tmp->group_name); + } + return 1; +}