aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@gmail.com>2022-02-16 12:45:39 -0500
committerJoseph Hunkeler <jhunkeler@gmail.com>2022-02-16 12:45:39 -0500
commita15215bf581d54b7b03da4649df2f9827ac72414 (patch)
tree916b4a8b45521feed8d6fb6ecbedcb93f55a7992 /lib
parent7c9ebcd4adc8596ac7f85211451a7bef213cf377 (diff)
downloadcleanpath-a15215bf581d54b7b03da4649df2f9827ac72414.tar.gz
Go by the part_nelem rather than length of data
Diffstat (limited to 'lib')
-rw-r--r--lib/cleanpath.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/cleanpath.c b/lib/cleanpath.c
index 5f7db0e..468c610 100644
--- a/lib/cleanpath.c
+++ b/lib/cleanpath.c
@@ -103,16 +103,22 @@ char *cleanpath_read(struct CleanPath *path) {
char *result;
size_t result_len;
size_t part_count;
+ size_t empty;
result = calloc(path->data_len, sizeof(char));
if (result == NULL) {
goto cleanpath_read__failure;
}
+ // Update number of elements in the path post-filter
+ empty = 0;
for (part_count = 0; path->part[part_count] != NULL; part_count++) {
- if (!strlen(path->part[part_count]))
+ if (!strlen(path->part[part_count])) {
+ empty++;
continue;
+ }
}
+ path->part_nelem = part_count - empty;
for (size_t i = 0; i < part_count; i++) {
// Ignore filtered paths