diff options
author | EuAndreh <eu@euandre.org> | 2024-06-04 16:39:08 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2024-06-04 16:39:08 -0300 |
commit | a2ab522c1267622286bbabd0fdb7791027738372 (patch) | |
tree | 9108f7220abf3224faf62ca07d0d24e622b815d6 | |
parent | tests/vector.c: Add simple test for next_size() (diff) | |
download | pindaiba-a2ab522c1267622286bbabd0fdb7791027738372.tar.gz pindaiba-a2ab522c1267622286bbabd0fdb7791027738372.tar.xz |
src/: Use freeit() for set_free(), string_free() and vector_free()
-rw-r--r-- | src/set.c | 3 | ||||
-rw-r--r-- | src/string.c | 6 | ||||
-rw-r--r-- | src/vector.c | 6 |
3 files changed, 7 insertions, 8 deletions
@@ -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 |