X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fplugin.c;h=ec9ede25472becfb906e62bea5d82a47514af576;hb=f46cf590f7e0a25fe5f826b762766f39e1f3a1f6;hp=7cf54c375ca52f269cf090d284950ef72c56ae86;hpb=e3f63afc6fc07e04540a42e69bdeab4928f1cd49;p=collectd.git diff --git a/src/plugin.c b/src/plugin.c index 7cf54c37..ec9ede25 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -79,6 +79,7 @@ static const char *plugin_get_dir (void) static int register_callback (llist_t **list, const char *name, void *callback) { llentry_t *le; + char *key; if ((*list == NULL) && ((*list = llist_create ()) == NULL)) @@ -87,9 +88,16 @@ static int register_callback (llist_t **list, const char *name, void *callback) le = llist_search (*list, name); if (le == NULL) { - le = llentry_create (name, callback); + key = strdup (name); + if (key == NULL) + return (-1); + + le = llentry_create (key, callback); if (le == NULL) + { + free (key); return (-1); + } llist_append (*list, le); } @@ -111,6 +119,7 @@ static int plugin_unregister (llist_t *list, const char *name) return (-1); llist_remove (list, e); + free (e->key); llentry_destroy (e); return (0); @@ -499,6 +508,7 @@ int plugin_unregister_read (const char *name) llist_remove (list_read, e); free (e->value); + free (e->key); llentry_destroy (e); return (0); @@ -529,6 +539,7 @@ int plugin_unregister_data_set (const char *name) llist_remove (list_data_set, e); ds = (data_set_t *) e->value; + free (e->key); llentry_destroy (e); sfree (ds->ds);