From 1fb424e7ade990e13dd87fd5c1bba5f3b480dea2 Mon Sep 17 00:00:00 2001 From: starnakin Date: Thu, 29 Jun 2023 11:44:58 +0200 Subject: [PATCH] add: tab_free --- src/tab/tab.h | 2 ++ src/tab/tab_free.c | 8 ++++++++ 2 files changed, 10 insertions(+) create mode 100644 src/tab/tab_free.c diff --git a/src/tab/tab.h b/src/tab/tab.h index 88de5d7..53e6e22 100644 --- a/src/tab/tab.h +++ b/src/tab/tab.h @@ -1,5 +1,7 @@ #pragma once +#include #include size_t tablen(const void** tab); +void tab_free(void** tab); diff --git a/src/tab/tab_free.c b/src/tab/tab_free.c new file mode 100644 index 0000000..516befb --- /dev/null +++ b/src/tab/tab_free.c @@ -0,0 +1,8 @@ +#include "tab.h" + +void tab_free(void** tab) +{ + for (size_t i = 0; tab[i] != NULL; i++) + free(tab[i]); + free(tab); +}