From: Martin Ling Date: Sun, 12 Oct 2014 14:56:36 +0000 (+0100) Subject: Track sdis created by sr_session_load(), and free in sr_session_destroy(). X-Git-Tag: libsigrok-0.4.0~861 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1de3ccede95a7b3535b67c6ade510715fe85d4d3;p=libsigrok.git Track sdis created by sr_session_load(), and free in sr_session_destroy(). --- diff --git a/src/libsigrok-internal.h b/src/libsigrok-internal.h index 3b7ea396..c94e4293 100644 --- a/src/libsigrok-internal.h +++ b/src/libsigrok-internal.h @@ -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; diff --git a/src/session.c b/src/session.c index 11da1378..f3232669 100644 --- a/src/session.c +++ b/src/session.c @@ -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; diff --git a/src/session_file.c b/src/session_file.c index 52d764dc..bd5b827f 100644 --- a/src/session_file.c +++ b/src/session_file.c @@ -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,