]> sigrok.org Git - libsigrok.git/commitdiff
std: Free channel groups from device instances as well.
authorBert Vermeulen <redacted>
Thu, 24 Jul 2014 19:01:08 +0000 (21:01 +0200)
committerBert Vermeulen <redacted>
Thu, 24 Jul 2014 19:01:08 +0000 (21:01 +0200)
src/std.c

index 2319dfef9273f47524fd61bcebb7535f8f21135b..910e884704ce64a169a3a4b60fb7aac7542bebe3 100644 (file)
--- 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);
        }