while (42)
{
- callback_func_t *cf;
+ read_func_t *rf;
- cf = c_heap_get_root (read_heap);
- if (cf == NULL)
+ rf = c_heap_get_root (read_heap);
+ if (rf == NULL)
break;
-
- destroy_callback (cf);
+ sfree (rf->rf_name);
+ destroy_callback ((callback_func_t *) rf);
}
c_heap_destroy (read_heap);
return (0);
} /* }}} int register_callback */
+static void log_list_callbacks (llist_t **list, /* {{{ */
+ const char *comment)
+{
+ char *str;
+ int len;
+ llentry_t *le;
+ int i;
+ int n;
+ char **keys;
+
+ n = llist_size(*list);
+ if (n == 0)
+ {
+ INFO("%s [none]", comment);
+ return;
+ }
+
+ keys = calloc(n, sizeof(char*));
+
+ if (keys == NULL)
+ {
+ ERROR("%s: failed to allocate memory for list of callbacks",
+ comment);
+
+ return;
+ }
+
+ for (le = llist_head (*list), i = 0, len = 0;
+ le != NULL;
+ le = le->next, i++)
+ {
+ keys[i] = le->key;
+ len += strlen(le->key) + 6;
+ }
+ str = malloc(len + 10);
+ if (str == NULL)
+ {
+ ERROR("%s: failed to allocate memory for list of callbacks",
+ comment);
+ }
+ else
+ {
+ *str = '\0';
+ strjoin(str, len, keys, n, "', '");
+ INFO("%s ['%s']", comment, str);
+ free(str);
+ }
+ free(keys);
+} /* }}} void log_list_callbacks */
+
static int create_register_callback (llist_t **list, /* {{{ */
const char *name, void *callback, user_data_t *ud)
{
rf->rf_interval = plugin_get_interval ();
status = plugin_insert_read (rf);
- if (status != 0)
+ if (status != 0) {
+ sfree (rf->rf_name);
sfree (rf);
+ }
return (status);
} /* int plugin_register_read */
rf->rf_ctx = plugin_get_ctx ();
status = plugin_insert_read (rf);
- if (status != 0)
+ if (status != 0) {
+ sfree (rf->rf_name);
sfree (rf);
+ }
return (status);
} /* int plugin_register_complex_read */
return (0);
} /* }}} int plugin_unregister_read */
+void plugin_log_available_writers (void)
+{
+ log_list_callbacks (&list_write, "Available write targets:");
+}
+
static int compare_read_func_group (llentry_t *e, void *ud) /* {{{ */
{
read_func_t *rf = e->value;
return_status = -1;
}
+ sfree (rf->rf_name);
destroy_callback ((void *) rf);
}