aboutsummaryrefslogtreecommitdiff
path: root/src/str.c
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2024-03-10 15:13:15 -0400
committerJoseph Hunkeler <jhunkeler@gmail.com>2024-03-10 15:13:15 -0400
commit4250d9bcfcf9dbc95418c64932ad39f71ff2019e (patch)
treea50b979c8817af4017e595928da6dc4524b37d40 /src/str.c
parented3f041df1d891b188fabfc055547c076ce6e85e (diff)
downloadstasis-4250d9bcfcf9dbc95418c64932ad39f71ff2019e.tar.gz
Use do/while in guard_* macros to make them behave more like functions
Diffstat (limited to 'src/str.c')
-rw-r--r--src/str.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/str.c b/src/str.c
index a51929a..9a4524c 100644
--- a/src/str.c
+++ b/src/str.c
@@ -134,7 +134,7 @@ long int strchroff(const char *sptr, int ch) {
}
result = tmp - orig;
- guard_free(orig)
+ guard_free(orig);
return result;
}
@@ -204,7 +204,7 @@ char** split(char *_sptr, const char* delim, size_t max)
// Preallocate enough records based on the number of delimiters
char **result = (char **)calloc(split_alloc + 2, sizeof(char *));
if (!result) {
- guard_free(sptr)
+ guard_free(sptr);
return NULL;
}
@@ -226,7 +226,7 @@ char** split(char *_sptr, const char* delim, size_t max)
break;
} else {
if (!result[i]) {
- guard_free(sptr_begin)
+ guard_free(sptr_begin);
return NULL;
}
strcpy(result[i], token);
@@ -235,7 +235,7 @@ char** split(char *_sptr, const char* delim, size_t max)
--x;
//memcpy(result[i], token, strlen(token) + 1); // copy the string contents into the record
}
- guard_free(sptr_begin)
+ guard_free(sptr_begin);
sptr_begin = NULL;
sptr = NULL;
return result;
@@ -247,9 +247,9 @@ char** split(char *_sptr, const char* delim, size_t max)
*/
void split_free(char **ptr) {
for (int i = 0; ptr[i] != NULL; i++) {
- guard_free(ptr[i])
+ guard_free(ptr[i]);
}
- guard_free(ptr)
+ guard_free(ptr);
}
/**
@@ -361,9 +361,9 @@ char *join_ex(char *separator, ...) {
if (i < (argc - 1)) {
strcat(result, separator);
}
- guard_free(argv[i])
+ guard_free(argv[i]);
}
- guard_free(argv)
+ guard_free(argv);
return result;
}
@@ -568,9 +568,9 @@ char **strdeldup(char **arr) {
result[rec] = strdup(arr[i]);
if (!result[rec]) {
for (size_t die = 0; result[die] != NULL; die++) {
- guard_free(result[die])
+ guard_free(result[die]);
}
- guard_free(result)
+ guard_free(result);
return NULL;
}
@@ -767,7 +767,7 @@ char *normalize_space(char *s) {
// Rewrite the input string
strcpy(result, tmp_orig);
- guard_free(tmp_orig)
+ guard_free(tmp_orig);
return result;
}