From 7aebe22d107df4548700bef900be66971658fcac Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Sat, 1 Nov 2014 13:18:09 +0100 Subject: [PATCH] Only sr_dev_inst_free() should free channel groups. --- src/device.c | 5 ++++- src/std.c | 10 +--------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/device.c b/src/device.c index 3d9cbf8f..051616f5 100644 --- a/src/device.c +++ b/src/device.c @@ -242,7 +242,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int status, /** @private * Free device instance struct created by sr_dev_inst(). - * @param sdi struct* to free. + * @param sdi device instance to free. */ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi) { @@ -260,7 +260,10 @@ SR_PRIV void sr_dev_inst_free(struct sr_dev_inst *sdi) for (l = sdi->channel_groups; l; l = l->next) { cg = l->data; + g_free(cg->name); + g_slist_free(cg->channels); g_free(cg->priv); + g_free(cg); } g_slist_free(sdi->channel_groups); diff --git a/src/std.c b/src/std.c index 7d78578d..fed47feb 100644 --- a/src/std.c +++ b/src/std.c @@ -249,8 +249,7 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, { struct drv_context *drvc; struct sr_dev_inst *sdi; - struct sr_channel_group *cg; - GSList *l, *lcg; + GSList *l; int ret; if (!(drvc = driver->priv)) @@ -285,13 +284,6 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, else g_free(sdi->priv); - /* Channel groups */ - for (lcg = sdi->channel_groups; lcg; lcg = lcg->next) { - cg = lcg->data; - g_free(cg->name); - g_slist_free(cg->channels); - g_free(cg); - } sr_dev_inst_free(sdi); }