projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
2f1955e
)
types_list: Do not free `ds' and `dsrc' because it's not copied in `plugin_register_d...
author
Florian Forster
<octo@huhu.verplant.org>
Thu, 3 May 2007 09:16:29 +0000
(11:16 +0200)
committer
Florian Forster
<octo@huhu.verplant.org>
Thu, 3 May 2007 09:16:29 +0000
(11:16 +0200)
This is a TODO.
src/types_list.c
patch
|
blob
|
history
diff --git
a/src/types_list.c
b/src/types_list.c
index
1bbf142
..
6fce019
100644
(file)
--- a/
src/types_list.c
+++ b/
src/types_list.c
@@
-95,37
+95,42
@@
static void parse_line (char *buf, size_t buf_len)
{
char *fields[64];
size_t fields_num;
{
char *fields[64];
size_t fields_num;
- data_set_t ds;
+ data_set_t
*
ds;
int i;
fields_num = strsplit (buf, fields, 64);
if (fields_num < 2)
return;
int i;
fields_num = strsplit (buf, fields, 64);
if (fields_num < 2)
return;
- memset (&ds, '\0', sizeof (ds));
+ ds = (data_set_t *) malloc (sizeof (data_set_t));
+ if (ds == NULL)
+ return;
+
+ memset (ds, '\0', sizeof (data_set_t));
- strncpy (ds
.type, fields[0], sizeof (ds.
type));
- ds
.type[sizeof (ds.
type) - 1] = '\0';
+ strncpy (ds
->type, fields[0], sizeof (ds->
type));
+ ds
->type[sizeof (ds->
type) - 1] = '\0';
- ds
.
ds_num = fields_num - 1;
- ds
.ds = (data_source_t *) calloc (ds.
ds_num, sizeof (data_source_t));
- if (ds
.
ds == NULL)
+ ds
->
ds_num = fields_num - 1;
+ ds
->ds = (data_source_t *) calloc (ds->
ds_num, sizeof (data_source_t));
+ if (ds
->
ds == NULL)
return;
return;
- for (i = 0; i < ds
.
ds_num; i++)
- if (parse_ds (ds
.
ds + i, fields[i + 1], strlen (fields[i + 1])) != 0)
+ for (i = 0; i < ds
->
ds_num; i++)
+ if (parse_ds (ds
->
ds + i, fields[i + 1], strlen (fields[i + 1])) != 0)
{
{
- sfree (ds
.
ds);
+ sfree (ds
->
ds);
ERROR ("types_list: parse_line: Cannot parse data source #%i "
ERROR ("types_list: parse_line: Cannot parse data source #%i "
- "of data set %s", i, ds
.
type);
+ "of data set %s", i, ds
->
type);
return;
}
DEBUG ("parse_line: ds = {%s, %i, %p};",
return;
}
DEBUG ("parse_line: ds = {%s, %i, %p};",
- ds
.type, ds.ds_num, (void *) ds.
ds);
+ ds
->type, ds->ds_num, (void *) ds->
ds);
- plugin_register_data_set (&ds);
- sfree (ds.ds);
+ plugin_register_data_set (ds);
+ /* Do NOT free `ds' and `ds->ds', because it's NOT copied by
+ * `plugin_register_data_set'!. */
} /* void parse_line */
static void parse_file (FILE *fh)
} /* void parse_line */
static void parse_file (FILE *fh)