From: Bert Vermeulen Date: Thu, 24 Jul 2014 19:01:08 +0000 (+0200) Subject: std: Free channel groups from device instances as well. X-Git-Tag: libsigrok-0.4.0~1208 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=886413b6d2e26513bd73f5d89f8b1816eda800a8;p=libsigrok.git std: Free channel groups from device instances as well. --- diff --git a/src/std.c b/src/std.c index 2319dfef..910e8847 100644 --- a/src/std.c +++ b/src/std.c @@ -249,7 +249,8 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, { struct drv_context *drvc; struct sr_dev_inst *sdi; - GSList *l; + struct sr_channel_group *cg; + GSList *l, *lcg; int ret; if (!(drvc = driver->priv)) @@ -278,9 +279,19 @@ SR_PRIV int std_dev_clear(const struct sr_dev_driver *driver, sr_scpi_free(sdi->conn); } if (clear_private) + /* The helper function is responsible for freeing + * its own sdi->priv! */ clear_private(sdi->priv); 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); }