diff options
author | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-04-28 09:00:05 (GMT) |
---|---|---|
committer | Lorenz Kästle <lorenz.kaestle@netways.de> | 2023-04-28 09:00:05 (GMT) |
commit | 34c4d13edd8ece1e928c578974218c10d25600c4 (patch) | |
tree | 96eaf64dc46c8b785d437250d42471180597a699 /lib/utils_disk.c | |
parent | e4ddeb7bb722b50613108da1cb51a48e84068701 (diff) | |
parent | 7cb82e6486e662fa4d2530523787d3eced266545 (diff) | |
download | monitoring-plugins-34c4d13edd8ece1e928c578974218c10d25600c4.tar.gz |
Merge branch 'master' into RincewindsHat-patch-1
Diffstat (limited to 'lib/utils_disk.c')
-rw-r--r-- | lib/utils_disk.c | 19 |
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) | |||
90 | struct parameter_list * | 95 | struct parameter_list * |
91 | np_del_parameter(struct parameter_list *item, struct parameter_list *prev) | 96 | np_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 | ||