]> sigrok.org Git - libsigrok.git/commitdiff
Only sr_dev_inst_free() should free channel groups.
authorBert Vermeulen <redacted>
Sat, 1 Nov 2014 12:18:09 +0000 (13:18 +0100)
committerBert Vermeulen <redacted>
Sat, 1 Nov 2014 12:20:00 +0000 (13:20 +0100)
src/device.c
src/std.c

index 3d9cbf8f9b5f27fa9e739c6b514a283ab9a16f8d..051616f5ad7935e79041403d1bd97b39149872b8 100644 (file)
@@ -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);
 
index 7d78578d5dfa802946ed3d279445d1788b0ffcd4..fed47febe3598e15468b0e2433b6decbd362fb48 100644 (file)
--- 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);
        }