]> sigrok.org Git - libsigrok.git/commitdiff
demo: Free analog channel groups when done with them.
authorBert Vermeulen <redacted>
Thu, 24 Jul 2014 19:01:39 +0000 (21:01 +0200)
committerBert Vermeulen <redacted>
Thu, 24 Jul 2014 19:01:39 +0000 (21:01 +0200)
This fixes a memory leak.

src/hardware/demo/demo.c

index a81217d7f7dc887e74d87b29efb0bba83b9177af..11e157ec8a89afd35b00082067bf148579e15e07 100644 (file)
@@ -379,9 +379,25 @@ static int dev_close(struct sr_dev_inst *sdi)
        return SR_OK;
 }
 
+static void clear_helper(void *priv)
+{
+       struct dev_context *devc;
+       struct sr_channel_group *cg;
+       GSList *l;
+
+       devc = priv;
+       for (l = devc->analog_channel_groups; l; l = l->next) {
+               cg = l->data;
+               /* Analog generators. */
+               g_free(cg->priv);
+       }
+       g_slist_free(devc->analog_channel_groups);
+       g_free(devc);
+}
+
 static int cleanup(void)
 {
-       return std_dev_clear(di, NULL);
+       return std_dev_clear(di, clear_helper);
 }
 
 static int config_get(int id, GVariant **data, const struct sr_dev_inst *sdi,