aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-03-22 18:21:10 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-03-22 22:20:30 -0400
commit664129de7d14bcfa4fe16e319d13a226b5087b82 (patch)
treeef84da5b38084f0211b6c15d8fc14fa85aa681e6 /src
parent9474f277a7ed4f3536b721cea721b25b30183d02 (diff)
downloadstasis-664129de7d14bcfa4fe16e319d13a226b5087b82.tar.gz
Replace free() with guard_* macros
Diffstat (limited to 'src')
-rw-r--r--src/strlist.c12
-rw-r--r--src/template.c2
-rw-r--r--src/utils.c2
3 files changed, 10 insertions, 6 deletions
diff --git a/src/strlist.c b/src/strlist.c
index c2250ee..50bf2de 100644
--- a/src/strlist.c
+++ b/src/strlist.c
@@ -16,13 +16,13 @@ void strlist_free(struct StrList *pStrList) {
}
for (size_t i = 0; i < pStrList->num_inuse; i++) {
if (pStrList->data[i]) {
- free(pStrList->data[i]);
+ guard_free(pStrList->data[i]);
}
}
if (pStrList->data) {
- free(pStrList->data);
+ guard_free(pStrList->data);
}
- free(pStrList);
+ guard_free(pStrList);
}
/**
@@ -39,7 +39,7 @@ void strlist_append(struct StrList *pStrList, char *str) {
tmp = realloc(pStrList->data, (pStrList->num_alloc + 1) * sizeof(char *));
if (tmp == NULL) {
- strlist_free(pStrList);
+ guard_strlist_free(pStrList);
perror("failed to append to array");
exit(1);
} else if (tmp != pStrList->data) {
@@ -98,9 +98,9 @@ int strlist_append_file(struct StrList *pStrList, char *_path, ReaderFn *readerF
for (size_t record = 0; data[record] != NULL; record++) {
strlist_append(pStrList, data[record]);
- free(data[record]);
+ guard_free(data[record]);
}
- free(data);
+ guard_free(data);
fatal:
if (filename != NULL) {
diff --git a/src/template.c b/src/template.c
index 39f01ac..7a5b0b9 100644
--- a/src/template.c
+++ b/src/template.c
@@ -45,9 +45,11 @@ void tpl_free() {
if (item) {
if (item->key) {
free(item->key);
+ guard_free(item->key);
}
free(item);
}
+ guard_free(item);
}
}
diff --git a/src/utils.c b/src/utils.c
index 74b4f6f..dd3dbe9 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -644,6 +644,8 @@ int fix_tox_conf(const char *filename, char **result) {
fclose(fptemp);
*result = tempfile;
+ guard_free(tempfile);
+
ini_free(&toxini);
return 0;
}