aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYordan Karadzhov <ykaradzhov@vmware.com>2019-03-05 16:39:22 +0200
committerSteven Rostedt (VMware) <rostedt@goodmis.org>2019-03-05 12:11:49 -0500
commitab266c8253d5737fb292794a9ab235a1de1f722d (patch)
tree219e6c308584cb5596078632b6fcfb604a591953
parent6e32054ed917a05e85875ba018f278afa7946955 (diff)
downloadtrace-cmd-ab266c8253d5737fb292794a9ab235a1de1f722d.tar.gz
kernel-shark: Define free_context function for the sched_events plugin
This static helper function makes the code of the plugin cleaner and easier to read. Link: http://lore.kernel.org/linux-trace-devel/20190305143924.11056-2-ykaradzhov@vmware.com Reviewed-by: Slavomir Kaslev <kaslevs@vmware.com> Signed-off-by: Yordan Karadzhov <ykaradzhov@vmware.com> Signed-off-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
-rw-r--r--kernel-shark/src/plugins/sched_events.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/kernel-shark/src/plugins/sched_events.c b/kernel-shark/src/plugins/sched_events.c
index 68734d4d..0d6de2dc 100644
--- a/kernel-shark/src/plugins/sched_events.c
+++ b/kernel-shark/src/plugins/sched_events.c
@@ -39,6 +39,17 @@ static bool define_wakeup_event(struct tep_handle *tep, const char *wakeup_name,
return true;
}
+static void plugin_free_context(struct plugin_sched_context *plugin_ctx)
+{
+ if (!plugin_ctx)
+ return;
+
+ tracecmd_filter_id_hash_free(plugin_ctx->second_pass_hash);
+ kshark_free_collection_list(plugin_ctx->collections);
+
+ free(plugin_ctx);
+}
+
static bool plugin_sched_init_context(struct kshark_context *kshark_ctx)
{
struct plugin_sched_context *plugin_ctx;
@@ -339,10 +350,7 @@ static int plugin_sched_close(struct kshark_context *kshark_ctx)
plugin_sched_action,
plugin_draw);
- tracecmd_filter_id_hash_free(plugin_ctx->second_pass_hash);
-
- kshark_free_collection_list(plugin_ctx->collections);
- free(plugin_ctx);
+ plugin_free_context(plugin_ctx);
plugin_sched_context_handler = NULL;
return 1;