From: Michal MalĂ˝ Date: Fri, 25 Jul 2014 19:12:12 +0000 (+0200) Subject: Implement rudimentary deinitialization X-Git-Url: https://gitweb.devoid-pointer.net/?a=commitdiff_plain;h=114c540b4d83b2afe6bd1343e50318af571bcb1f;p=KLGD.git Implement rudimentary deinitialization --- diff --git a/klgd.c b/klgd.c index 86c9f53..7de26a3 100644 --- a/klgd.c +++ b/klgd.c @@ -82,6 +82,23 @@ void klgd_free_stream(struct klgd_command_stream *s) } } +void klgd_deinit(struct klgd_main *ctx) +{ + struct klgd_main_private *priv = ctx->private; + size_t idx; + + for (idx = 0; idx < priv->plugin_count; idx++) { + struct klgd_plugin *plugin = priv->plugins[idx]; + + plugin->deinit(plugin); + kfree(plugin); + } + kfree(priv->plugins); + + kfree(priv); + kfree(ctx); +} + int klgd_init(struct klgd_main *ctx, void *dev_ctx, int (*callback)(void *, struct klgd_command_stream *), const size_t plugin_count) { struct klgd_main_private *priv = ctx->private; diff --git a/klgd.h b/klgd.h index 4eaef24..b9ee33c 100644 --- a/klgd.h +++ b/klgd.h @@ -15,7 +15,7 @@ struct klgd_main { struct klgd_plugin { struct klgd_plugin_private *private; - void (*deinit)(struct klgd_plugin *ctx, void *data); + void (*deinit)(struct klgd_plugin *ctx); struct klgd_command_stream *(*get_commands)(struct klgd_plugin *ctx, const unsigned long now); bool (*get_update_time)(struct klgd_plugin *ctx, const unsigned long now, unsigned long *t); int (*init)(struct klgd_plugin *ctx, void *data); @@ -23,7 +23,7 @@ struct klgd_plugin { int (*post_event)(struct klgd_plugin *ctx, void *data); }; -void klgd_deinit(struct klgd_main *ctx, void *data); +void klgd_deinit(struct klgd_main *ctx); int klgd_init(struct klgd_main *ctx, void *dev_ctx, int (*callback)(void *, struct klgd_command_stream *), const unsigned long plugin_count); void klgd_notify_commands_sent(struct klgd_main *ctx); int klgd_post_event(struct klgd_main *ctx, const size_t idx, void *data);