projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
battery plugin: constify
[collectd.git]
/
src
/
daemon
/
configfile.c
diff --git
a/src/daemon/configfile.c
b/src/daemon/configfile.c
index
f367ee9
..
8a7621d
100644
(file)
--- a/
src/daemon/configfile.c
+++ b/
src/daemon/configfile.c
@@
-72,15
+72,15
@@
typedef struct cf_complex_callback_s
typedef struct cf_value_map_s
{
typedef struct cf_value_map_s
{
- char *key;
+ c
onst c
har *key;
int (*func) (oconfig_item_t *);
} cf_value_map_t;
typedef struct cf_global_option_s
{
int (*func) (oconfig_item_t *);
} cf_value_map_t;
typedef struct cf_global_option_s
{
- char *key;
+ c
onst c
har *key;
char *value;
char *value;
- char *def;
+ c
onst c
har *def;
} cf_global_option_t;
/*
} cf_global_option_t;
/*
@@
-381,7
+381,7
@@
static int dispatch_value (oconfig_item_t *ci)
static int dispatch_block_plugin (oconfig_item_t *ci)
{
int i;
static int dispatch_block_plugin (oconfig_item_t *ci)
{
int i;
- char *name;
+ c
onst c
har *name;
cf_complex_callback_t *cb;
cf_complex_callback_t *cb;
@@
-628,8
+628,11
@@
static int cf_include_all (oconfig_item_t *root, int depth)
return (-1);
/* Now replace the i'th child in `root' with `new'. */
return (-1);
/* Now replace the i'th child in `root' with `new'. */
- if (cf_ci_replace_child (root, new, i) < 0)
+ if (cf_ci_replace_child (root, new, i) < 0) {
+ sfree (new->values);
+ sfree (new);
return (-1);
return (-1);
+ }
/* ... and go back to the new i'th child. */
--i;
/* ... and go back to the new i'th child. */
--i;
@@
-718,6
+721,7
@@
static oconfig_item_t *cf_read_dir (const char *dir,
if (root == NULL)
{
ERROR ("configfile: malloc failed.");
if (root == NULL)
{
ERROR ("configfile: malloc failed.");
+ closedir (dh);
return (NULL);
}
memset (root, 0, sizeof (oconfig_item_t));
return (NULL);
}
memset (root, 0, sizeof (oconfig_item_t));
@@
-737,6
+741,7
@@
static oconfig_item_t *cf_read_dir (const char *dir,
ERROR ("configfile: Not including `%s/%s' because its"
" name is too long.",
dir, de->d_name);
ERROR ("configfile: Not including `%s/%s' because its"
" name is too long.",
dir, de->d_name);
+ closedir (dh);
for (i = 0; i < filenames_num; ++i)
free (filenames[i]);
free (filenames);
for (i = 0; i < filenames_num; ++i)
free (filenames[i]);
free (filenames);
@@
-749,6
+754,7
@@
static oconfig_item_t *cf_read_dir (const char *dir,
filenames_num * sizeof (*filenames));
if (tmp == NULL) {
ERROR ("configfile: realloc failed.");
filenames_num * sizeof (*filenames));
if (tmp == NULL) {
ERROR ("configfile: realloc failed.");
+ closedir (dh);
for (i = 0; i < filenames_num - 1; ++i)
free (filenames[i]);
free (filenames);
for (i = 0; i < filenames_num - 1; ++i)
free (filenames[i]);
free (filenames);
@@
-761,7
+767,10
@@
static oconfig_item_t *cf_read_dir (const char *dir,
}
if (filenames == NULL)
}
if (filenames == NULL)
+ {
+ closedir (dh);
return (root);
return (root);
+ }
qsort ((void *) filenames, filenames_num, sizeof (*filenames),
cf_compare_string);
qsort ((void *) filenames, filenames_num, sizeof (*filenames),
cf_compare_string);
@@
-786,11
+795,12
@@
static oconfig_item_t *cf_read_dir (const char *dir,
free (name);
}
free (name);
}
+ closedir (dh);
free(filenames);
return (root);
} /* oconfig_item_t *cf_read_dir */
free(filenames);
return (root);
} /* oconfig_item_t *cf_read_dir */
-/*
+/*
* cf_read_generic
*
* Path is stat'ed and either cf_read_file or cf_read_dir is called
* cf_read_generic
*
* Path is stat'ed and either cf_read_file or cf_read_dir is called
@@
-1105,7
+1115,7
@@
int cf_register_complex (const char *type, int (*callback) (oconfig_item_t *))
return (0);
} /* int cf_register_complex */
return (0);
} /* int cf_register_complex */
-int cf_read (char *filename)
+int cf_read (c
onst c
har *filename)
{
oconfig_item_t *conf;
int i;
{
oconfig_item_t *conf;
int i;