aboutsummaryrefslogtreecommitdiff
path: root/include/fstree.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-19 10:13:49 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2023-04-19 11:17:54 +0200
commite1e655b02f6c54177f9070eeb221ab95c6d4e20f (patch)
treeb5e64c6aa8ca6121858e49f691aaf87de329081b /include/fstree.h
parent982db0d8d6fdc32d605f716bd891b5bbc4838608 (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 'include/fstree.h')
-rw-r--r--include/fstree.h10
1 files changed, 3 insertions, 7 deletions
diff --git a/include/fstree.h b/include/fstree.h
index 1a7ad30..044bb48 100644
--- a/include/fstree.h
+++ b/include/fstree.h
@@ -26,9 +26,6 @@ typedef struct tree_node_t tree_node_t;
typedef struct file_info_t file_info_t;
typedef struct fstree_t fstree_t;
-#define container_of(ptr, type, member) \
- ((type *)((char *)ptr - offsetof(type, member)))
-
enum {
FLAG_DIR_CREATED_IMPLICITLY = 0x01,
FLAG_FILE_ALREADY_MATCHED = 0x02,
@@ -36,9 +33,6 @@ enum {
/* Additional meta data stored in a tree_node_t for regular files. */
struct file_info_t {
- /* Linked list pointer for files in fstree_t */
- file_info_t *next;
-
/* Path to the input file. */
char *input_file;
@@ -51,6 +45,8 @@ struct file_info_t {
/* A node in a file system tree */
struct tree_node_t {
+ tree_node_t *next_by_type;
+
/* Parent directory children linked list pointer. */
tree_node_t *next;
@@ -108,7 +104,7 @@ struct fstree_t {
tree_node_t *root;
/* linear linked list of all regular files */
- file_info_t *files;
+ tree_node_t *files;
};
/*