summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/utils_disk.c19
-rw-r--r--lib/utils_disk.h1
2 files changed, 18 insertions, 2 deletions
diff --git a/lib/utils_disk.c b/lib/utils_disk.c
index 4f16068..468769b 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -47,9 +47,10 @@ np_add_parameter(struct parameter_list **list, const char *name)
47 struct parameter_list *current = *list; 47 struct parameter_list *current = *list;
48 struct parameter_list *new_path; 48 struct parameter_list *new_path;
49 new_path = (struct parameter_list *) malloc (sizeof *new_path); 49 new_path = (struct parameter_list *) malloc (sizeof *new_path);
50 new_path->name = (char *) name; 50 new_path->name = (char *) malloc(strlen(name) + 1);
51 new_path->best_match = NULL; 51 new_path->best_match = NULL;
52 new_path->name_next = NULL; 52 new_path->name_next = NULL;
53 new_path->name_prev = NULL;
53 new_path->freespace_bytes = NULL; 54 new_path->freespace_bytes = NULL;
54 new_path->freespace_units = NULL; 55 new_path->freespace_units = NULL;
55 new_path->freespace_percent = NULL; 56 new_path->freespace_percent = NULL;
@@ -75,13 +76,17 @@ np_add_parameter(struct parameter_list **list, const char *name)
75 new_path->dused_inodes_percent = 0; 76 new_path->dused_inodes_percent = 0;
76 new_path->dfree_inodes_percent = 0; 77 new_path->dfree_inodes_percent = 0;
77 78
79 strcpy(new_path->name, name);
80
78 if (current == NULL) { 81 if (current == NULL) {
79 *list = new_path; 82 *list = new_path;
83 new_path->name_prev = NULL;
80 } else { 84 } else {
81 while (current->name_next) { 85 while (current->name_next) {
82 current = current->name_next; 86 current = current->name_next;
83 } 87 }
84 current->name_next = new_path; 88 current->name_next = new_path;
89 new_path->name_prev = current;
85 } 90 }
86 return new_path; 91 return new_path;
87} 92}
@@ -90,6 +95,9 @@ np_add_parameter(struct parameter_list **list, const char *name)
90struct parameter_list * 95struct parameter_list *
91np_del_parameter(struct parameter_list *item, struct parameter_list *prev) 96np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
92{ 97{
98 if (item == NULL) {
99 return NULL;
100 }
93 struct parameter_list *next; 101 struct parameter_list *next;
94 102
95 if (item->name_next) 103 if (item->name_next)
@@ -97,10 +105,17 @@ np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
97 else 105 else
98 next = NULL; 106 next = NULL;
99 107
100 free(item); 108 if (next)
109 next->name_prev = prev;
110
101 if (prev) 111 if (prev)
102 prev->name_next = next; 112 prev->name_next = next;
103 113
114 if (item->name) {
115 free(item->name);
116 }
117 free(item);
118
104 return next; 119 return next;
105} 120}
106 121
diff --git a/lib/utils_disk.h b/lib/utils_disk.h
index bf52e4c..3b5a45f 100644
--- a/lib/utils_disk.h
+++ b/lib/utils_disk.h
@@ -24,6 +24,7 @@ struct parameter_list
24 char *group; 24 char *group;
25 struct mount_entry *best_match; 25 struct mount_entry *best_match;
26 struct parameter_list *name_next; 26 struct parameter_list *name_next;
27 struct parameter_list *name_prev;
27 uintmax_t total, available, available_to_root, used, 28 uintmax_t total, available, available_to_root, used,
28 inodes_free, inodes_free_to_root, inodes_used, inodes_total; 29 inodes_free, inodes_free_to_root, inodes_used, inodes_total;
29 double dfree_pct, dused_pct; 30 double dfree_pct, dused_pct;