Track sdis created by sr_session_load(), and free in sr_session_destroy().

This commit is contained in:
Martin Ling 2014-10-12 15:56:36 +01:00 committed by Bert Vermeulen
parent c0e3ba4b79
commit 1de3ccede9
3 changed files with 6 additions and 0 deletions

View 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;

View 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;

View 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,