From: Daniel Wagner <daniel.wag...@bmw-carit.de>

We want to reuse this code snippet for the error case in
__connman_session_create() too.
---
 src/session.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/src/session.c b/src/session.c
index 3d497b8..e489742 100644
--- a/src/session.c
+++ b/src/session.c
@@ -878,6 +878,19 @@ static gint sort_services(gconstpointer a, gconstpointer 
b, gpointer user_data)
                                session);
 }
 
+static void free_session(struct connman_session *session)
+{
+       destroy_policy_config(session);
+       connman_session_free_bearers(session->info->config.allowed_bearers);
+       g_free(session->owner);
+       g_free(session->session_path);
+       g_free(session->notify_path);
+       g_free(session->info);
+       g_free(session->info_last);
+
+       g_free(session);
+}
+
 static void cleanup_session(gpointer user_data)
 {
        struct connman_session *session = user_data;
@@ -893,15 +906,7 @@ static void cleanup_session(gpointer user_data)
                __connman_service_disconnect(info->entry->service);
        }
 
-       destroy_policy_config(session);
-       connman_session_free_bearers(session->info->config.allowed_bearers);
-       g_free(session->owner);
-       g_free(session->session_path);
-       g_free(session->notify_path);
-       g_free(session->info);
-       g_free(session->info_last);
-
-       g_free(session);
+       free_session(session);
 }
 
 static enum connman_session_state service_to_session_state(enum 
connman_service_state state)
-- 
1.7.11.4

_______________________________________________
connman mailing list
connman@connman.net
http://lists.connman.net/listinfo/connman

Reply via email to