From 03bae825694499a601e623d565bfd0b3e2ddfa5b Mon Sep 17 00:00:00 2001 From: GreekStapler Date: Sun, 29 Jan 2023 11:55:22 +0000 Subject: [PATCH] refactor: Added free function for package struct. While going through with the renaming, I saw that I actually forgot to implement that part. --- src/package/vieter_package.c | 9 +++++++++ test/package/test_package.c | 2 ++ 2 files changed, 11 insertions(+) diff --git a/src/package/vieter_package.c b/src/package/vieter_package.c index a3d2cd6..4a6515c 100644 --- a/src/package/vieter_package.c +++ b/src/package/vieter_package.c @@ -221,3 +221,12 @@ char *vieter_package_to_description(Pkg *pkg) { return description; } + +void vieter_package_free(Pkg **ptp) { + FREE_STRING((*ptp)->path); + vieter_package_info_free((*ptp)->info); + vieter_package_dynarray_free((*ptp)->files); + free(*ptp); + *ptp = NULL; + +} diff --git a/test/package/test_package.c b/test/package/test_package.c index a79d5df..f6597c8 100644 --- a/test/package/test_package.c +++ b/test/package/test_package.c @@ -57,6 +57,8 @@ void test_pkg_read_archive_files() { } TEST_CHECK(pkg->compression = 14); + vieter_package_free(&pkg); + } void test_pkg_read_archive_desc() {