int plugin_register_data_set (const data_set_t *ds)
{
- return (register_callback (&list_data_set, ds->type, (void *) ds));
+ data_set_t *ds_copy;
+ int i;
+
+ if (llist_search (list_data_set, ds->type) != NULL)
+ {
+ NOTICE ("Replacing DS `%s' with another version.", ds->type);
+ plugin_unregister_data_set (ds->type);
+ }
+
+ ds_copy = (data_set_t *) malloc (sizeof (data_set_t));
+ if (ds_copy == NULL)
+ return (-1);
+ memcpy(ds_copy, ds, sizeof (data_set_t));
+
+ ds_copy->ds = (data_source_t *) malloc (sizeof (data_source_t)
+ * ds->ds_num);
+ if (ds_copy->ds == NULL)
+ {
+ free (ds_copy);
+ return (-1);
+ }
+
+ for (i = 0; i < ds->ds_num; i++)
+ memcpy (ds_copy->ds + i, ds->ds + i, sizeof (data_source_t));
+
+ return (register_callback (&list_data_set, ds->type, (void *) ds_copy));
} /* int plugin_register_data_set */
int plugin_register_log (char *name,
int plugin_unregister_data_set (const char *name)
{
- return (plugin_unregister (list_data_set, name));
-}
+ llentry_t *e;
+ data_set_t *ds;
+
+ e = llist_search (list_data_set, name);
+
+ if (e == NULL)
+ return (-1);
+
+ llist_remove (list_data_set, e);
+ ds = (data_set_t *) e->value;
+ llentry_destroy (e);
+
+ sfree (ds->ds);
+ sfree (ds);
+
+ return (0);
+} /* int plugin_unregister_data_set */
int plugin_unregister_log (const char *name)
{
ds->type, ds->ds_num, (void *) ds->ds);
plugin_register_data_set (ds);
- /* Do NOT free `ds' and `ds->ds', because it's NOT copied by
- * `plugin_register_data_set'!. */
+
+ sfree (ds->ds);
+ sfree (ds);
} /* void parse_line */
static void parse_file (FILE *fh)