projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branch 'collectd-5.8'
[collectd.git]
/
src
/
table.c
diff --git
a/src/table.c
b/src/table.c
index
7cae3f7
..
bc82542
100644
(file)
--- a/
src/table.c
+++ b/
src/table.c
@@
-78,6
+78,10
@@
static void tbl_result_setup(tbl_result_t *res) {
} /* tbl_result_setup */
static void tbl_result_clear(tbl_result_t *res) {
} /* tbl_result_setup */
static void tbl_result_clear(tbl_result_t *res) {
+ if (res == NULL) {
+ return;
+ }
+
sfree(res->type);
sfree(res->instance_prefix);
sfree(res->type);
sfree(res->instance_prefix);
@@
-103,11
+107,17
@@
static void tbl_setup(tbl_t *tbl, char *file) {
} /* tbl_setup */
static void tbl_clear(tbl_t *tbl) {
} /* tbl_setup */
static void tbl_clear(tbl_t *tbl) {
+ if (tbl == NULL) {
+ return;
+ }
+
sfree(tbl->file);
sfree(tbl->sep);
sfree(tbl->plugin_name);
sfree(tbl->instance);
sfree(tbl->file);
sfree(tbl->sep);
sfree(tbl->plugin_name);
sfree(tbl->instance);
+ /* (tbl->results == NULL) -> (tbl->results_num == 0) */
+ assert((tbl->results != NULL) || (tbl->results_num == 0));
for (size_t i = 0; i < tbl->results_num; ++i)
tbl_result_clear(tbl->results + i);
sfree(tbl->results);
for (size_t i = 0; i < tbl->results_num; ++i)
tbl_result_clear(tbl->results + i);
sfree(tbl->results);
@@
-154,8
+164,7
@@
static int tbl_config_append_array_i(char *name, size_t **var, size_t *len,
tmp = realloc(*var, ((*len) + num) * sizeof(**var));
if (NULL == tmp) {
tmp = realloc(*var, ((*len) + num) * sizeof(**var));
if (NULL == tmp) {
- char errbuf[1024];
- log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("realloc failed: %s.", STRERRNO);
return -1;
}
*var = tmp;
return -1;
}
*var = tmp;
@@
-177,8
+186,7
@@
static int tbl_config_result(tbl_t *tbl, oconfig_item_t *ci) {
tbl_result_t *res =
realloc(tbl->results, (tbl->results_num + 1) * sizeof(*tbl->results));
if (res == NULL) {
tbl_result_t *res =
realloc(tbl->results, (tbl->results_num + 1) * sizeof(*tbl->results));
if (res == NULL) {
- char errbuf[1024];
- log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("realloc failed: %s.", STRERRNO);
return -1;
}
return -1;
}
@@
-235,8
+243,7
@@
static int tbl_config_table(oconfig_item_t *ci) {
tbl_t *tbl = realloc(tables, (tables_num + 1) * sizeof(*tables));
if (NULL == tbl) {
tbl_t *tbl = realloc(tables, (tables_num + 1) * sizeof(*tables));
if (NULL == tbl) {
- char errbuf[1024];
- log_err("realloc failed: %s.", sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("realloc failed: %s.", STRERRNO);
return -1;
}
return -1;
}
@@
-443,9
+450,7
@@
static int tbl_read_table(tbl_t *tbl) {
fh = fopen(tbl->file, "r");
if (NULL == fh) {
fh = fopen(tbl->file, "r");
if (NULL == fh) {
- char errbuf[1024];
- log_err("Failed to open file \"%s\": %s.", tbl->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("Failed to open file \"%s\": %s.", tbl->file, STRERRNO);
return -1;
}
return -1;
}
@@
-463,9
+468,7
@@
static int tbl_read_table(tbl_t *tbl) {
}
if (0 != ferror(fh)) {
}
if (0 != ferror(fh)) {
- char errbuf[1024];
- log_err("Failed to read from file \"%s\": %s.", tbl->file,
- sstrerror(errno, errbuf, sizeof(errbuf)));
+ log_err("Failed to read from file \"%s\": %s.", tbl->file, STRERRNO);
fclose(fh);
return -1;
}
fclose(fh);
return -1;
}