diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-19 10:13:49 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-04-19 11:17:54 +0200 |
commit | e1e655b02f6c54177f9070eeb221ab95c6d4e20f (patch) | |
tree | b5e64c6aa8ca6121858e49f691aaf87de329081b /lib/fstree/src | |
parent | 982db0d8d6fdc32d605f716bd891b5bbc4838608 (diff) |
libfstree: hoist file link pointer into parent structure
Instead of having a file_info_t next pointer, requiring an up-cast
to tree_node_t all the time, simply add a "next_by_type" pointer to
the tree node itself, which can also be used for other purposes by
other node types and removes the need for up-casting.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/fstree/src')
-rw-r--r-- | lib/fstree/src/post_process.c | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/lib/fstree/src/post_process.c b/lib/fstree/src/post_process.c index 5bf7e7d..f8bc0f7 100644 --- a/lib/fstree/src/post_process.c +++ b/lib/fstree/src/post_process.c @@ -55,15 +55,15 @@ fail_ov: return -1; } -static file_info_t *file_list_dfs(tree_node_t *n) +static tree_node_t *file_list_dfs(tree_node_t *n) { if (S_ISREG(n->mode)) { - n->data.file.next = NULL; - return &n->data.file; + n->next_by_type = NULL; + return n; } if (S_ISDIR(n->mode)) { - file_info_t *list = NULL, *last = NULL; + tree_node_t *list = NULL, *last = NULL; for (n = n->data.children; n != NULL; n = n->next) { if (list == NULL) { @@ -72,11 +72,11 @@ static file_info_t *file_list_dfs(tree_node_t *n) continue; last = list; } else { - last->next = file_list_dfs(n); + last->next_by_type = file_list_dfs(n); } - while (last->next != NULL) - last = last->next; + while (last->next_by_type != NULL) + last = last->next_by_type; } return list; |