libmpm

morphux C package management library
Log | Files | Refs | Submodules | README | LICENSE | git clone https://git.ne02ptzero.me/git/libmpm

commit 03052d23ba28cb260f5bd1a8dc9c7dba9ee07b28
parent b9e10f229b8beb6553e389c17c754a624a6085da
Author: Ne02ptzero <louis@ne02ptzero.me>
Date:   Sat, 28 Jan 2017 16:16:23 +0100

Fix(Valgrind): Fix tests, and internal API

Diffstat:
Msrc/database.c | 6++----
Mtests/test_database.c | 9+--------
2 files changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/database.c b/src/database.c @@ -58,15 +58,13 @@ error: * On any error, this function will return the error code. */ u8_t mpm_database_close(mdatabase_t *ptr) { - u8_t error; + u8_t error = 1; if (ptr != NULL) { error = sqlite3_close(ptr->sql); - if (error != 0) - return error; free(ptr); } - return 0; + return error; } /*! diff --git a/tests/test_database.c b/tests/test_database.c @@ -25,17 +25,10 @@ TEST(database_open_2) { TEST(database_close_1) { - mdatabase_t *ptr = NULL; u8_t ret = 0; - /* Fake mallocs */ - ptr = malloc(sizeof(mdatabase_t)); - ptr->sql = malloc(10); - - ret = mpm_database_close(ptr); + ret = mpm_database_close(NULL); TEST_ASSERT(ret != 0, "Error did not trigger"); - free(ptr->sql); - free(ptr); return TEST_SUCCESS; }