]> sigrok.org Git - libsigrok.git/commitdiff
Track sdis created by sr_session_load(), and free in sr_session_destroy().
authorMartin Ling <redacted>
Sun, 12 Oct 2014 14:56:36 +0000 (15:56 +0100)
committerBert Vermeulen <redacted>
Wed, 15 Oct 2014 11:44:25 +0000 (13:44 +0200)
src/libsigrok-internal.h
src/session.c
src/session_file.c

index 3b7ea39624645f7a68a6a0a74b4072080805285d..c94e42932ea1ba5cd7dfad12b8b2f1b641efc8f1 100644 (file)
@@ -535,6 +535,8 @@ SR_PRIV int sr_source_add_channel(GIOChannel *channel, int events, int timeout,
 struct sr_session {
        /** List of struct sr_dev_inst pointers. */
        GSList *devs;
+       /** List of struct sr_dev_inst pointers owned by this session. */
+       GSList *owned_devs;
        /** List of struct datafeed_callback pointers. */
        GSList *datafeed_callbacks;
        struct sr_trigger *trigger;
index 11da1378b56508c67c804d66bbb3169f429ea7ad..f32326694e8fe9b8fba82e7d963f27adad28a004 100644 (file)
@@ -113,6 +113,8 @@ SR_API int sr_session_destroy(struct sr_session *session)
        if (session->trigger)
                sr_trigger_free(session->trigger);
 
+       g_slist_free_full(session->owned_devs, (GDestroyNotify)sr_dev_inst_free);
+
        g_free(session);
 
        return SR_OK;
index 52d764dc68e88122a7203ccc33a8b14dffb00271..bd5b827f41734abf8ceb3056c31c264b26d5ba63 100644 (file)
@@ -179,6 +179,8 @@ SR_API int sr_session_load(const char *filename, struct sr_session **session)
                                        }
                                        sr_dev_open(sdi);
                                        sr_session_dev_add(*session, sdi);
+                                       (*session)->owned_devs = g_slist_append(
+                                                       (*session)->owned_devs, sdi);
                                        sdi->driver->config_set(SR_CONF_SESSIONFILE,
                                                        g_variant_new_string(filename), sdi, NULL);
                                        sdi->driver->config_set(SR_CONF_CAPTUREFILE,