summaryrefslogtreecommitdiffstats
path: root/lib/utils_disk.c
diff options
context:
space:
mode:
authorLorenz <12514511+RincewindsHat@users.noreply.github.com>2023-03-11 10:34:47 (GMT)
committerGitHub <noreply@github.com>2023-03-11 10:34:47 (GMT)
commit75342b53853a898bdd93c7d3da9374115bab6b6d (patch)
tree0c0af2b796bcdd8ddd42187beb5badb420db8dea /lib/utils_disk.c
parent6bbe0b7b0f609ecab831dec9be7690842bf0a0fc (diff)
parent357787868b5201ec3e874e7a225b1c944cbbdb4d (diff)
downloadmonitoring-plugins-75342b53853a898bdd93c7d3da9374115bab6b6d.tar.gz
Merge branch 'master' into patch-1refs/pull/1842/head
Diffstat (limited to 'lib/utils_disk.c')
-rw-r--r--lib/utils_disk.c19
1 files changed, 17 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