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 c7c9126..a1181d3 100644
--- a/lib/utils_disk.c
+++ b/lib/utils_disk.c
@@ -46,9 +46,10 @@ np_add_parameter(struct parameter_list **list, const char *name)
46 struct parameter_list *current = *list; 46 struct parameter_list *current = *list;
47 struct parameter_list *new_path; 47 struct parameter_list *new_path;
48 new_path = (struct parameter_list *) malloc (sizeof *new_path); 48 new_path = (struct parameter_list *) malloc (sizeof *new_path);
49 new_path->name = (char *) name; 49 new_path->name = (char *) malloc(strlen(name) + 1);
50 new_path->best_match = NULL; 50 new_path->best_match = NULL;
51 new_path->name_next = NULL; 51 new_path->name_next = NULL;
52 new_path->name_prev = NULL;
52 new_path->freespace_bytes = NULL; 53 new_path->freespace_bytes = NULL;
53 new_path->freespace_units = NULL; 54 new_path->freespace_units = NULL;
54 new_path->freespace_percent = NULL; 55 new_path->freespace_percent = NULL;
@@ -74,13 +75,17 @@ np_add_parameter(struct parameter_list **list, const char *name)
74 new_path->dused_inodes_percent = 0; 75 new_path->dused_inodes_percent = 0;
75 new_path->dfree_inodes_percent = 0; 76 new_path->dfree_inodes_percent = 0;
76 77
78 strcpy(new_path->name, name);
79
77 if (current == NULL) { 80 if (current == NULL) {
78 *list = new_path; 81 *list = new_path;
82 new_path->name_prev = NULL;
79 } else { 83 } else {
80 while (current->name_next) { 84 while (current->name_next) {
81 current = current->name_next; 85 current = current->name_next;
82 } 86 }
83 current->name_next = new_path; 87 current->name_next = new_path;
88 new_path->name_prev = current;
84 } 89 }
85 return new_path; 90 return new_path;
86} 91}
@@ -89,6 +94,9 @@ np_add_parameter(struct parameter_list **list, const char *name)
89struct parameter_list * 94struct parameter_list *
90np_del_parameter(struct parameter_list *item, struct parameter_list *prev) 95np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
91{ 96{
97 if (item == NULL) {
98 return NULL;
99 }
92 struct parameter_list *next; 100 struct parameter_list *next;
93 101
94 if (item->name_next) 102 if (item->name_next)
@@ -96,10 +104,17 @@ np_del_parameter(struct parameter_list *item, struct parameter_list *prev)
96 else 104 else
97 next = NULL; 105 next = NULL;
98 106
99 free(item); 107 if (next)
108 next->name_prev = prev;
109
100 if (prev) 110 if (prev)
101 prev->name_next = next; 111 prev->name_next = next;
102 112
113 if (item->name) {
114 free(item->name);
115 }
116 free(item);
117
103 return next; 118 return next;
104} 119}
105 120
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;