summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEuAndreh <eu@euandre.org>2024-06-04 16:39:08 -0300
committerEuAndreh <eu@euandre.org>2024-06-04 16:39:08 -0300
commita2ab522c1267622286bbabd0fdb7791027738372 (patch)
tree9108f7220abf3224faf62ca07d0d24e622b815d6 /src
parenttests/vector.c: Add simple test for next_size() (diff)
downloadpindaiba-a2ab522c1267622286bbabd0fdb7791027738372.tar.gz
pindaiba-a2ab522c1267622286bbabd0fdb7791027738372.tar.xz
src/: Use freeit() for set_free(), string_free() and vector_free()
Diffstat (limited to 'src')
-rw-r--r--src/set.c3
-rw-r--r--src/string.c6
-rw-r--r--src/vector.c6
3 files changed, 7 insertions, 8 deletions
diff --git a/src/set.c b/src/set.c
index 465a141..1a5fc92 100644
--- a/src/set.c
+++ b/src/set.c
@@ -70,6 +70,5 @@ set_free(const struct Set **const s) {
assert((*s) != NULL);
const struct Vector *table = (*s)->table;
vector_free(&table);
- free((void *)*s);
- *s = NULL;
+ freeit((void *)s);
}
diff --git a/src/string.c b/src/string.c
index 7db6652..74fe2bd 100644
--- a/src/string.c
+++ b/src/string.c
@@ -74,9 +74,9 @@ string_new(const char *const string, const struct String **const out) {
void
string_free(const struct String **const s) {
- free((void *)(*s)->bytes);
- free((void *)(*s));
- *s = NULL;
+ const uint8_t *bytes = (*s)->bytes;
+ freeit((void *)&bytes);
+ freeit((void *)s);
}
const char *
diff --git a/src/vector.c b/src/vector.c
index 72b41e2..24d72b7 100644
--- a/src/vector.c
+++ b/src/vector.c
@@ -113,9 +113,9 @@ vector_new(const size_t value_size, const struct Vector **const out) {
void
vector_free(const struct Vector **const v) {
assert((*v) != NULL);
- free((*v)->values);
- free((void *)*v);
- *v = NULL;
+ const void **values = (*v)->values;
+ freeit((void *)&values);
+ freeit((void *)v);
}
size_t